wip
This commit is contained in:
parent
3a645d21dc
commit
33cb0dd7da
|
|
@ -1,5 +1,10 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="LaravelPint">
|
||||||
|
<laravel_pint_settings>
|
||||||
|
<LaravelPintConfiguration tool_path="$PROJECT_DIR$/laravel_app/vendor/bin/pint" />
|
||||||
|
</laravel_pint_settings>
|
||||||
|
</component>
|
||||||
<component name="MessDetectorOptionsConfiguration">
|
<component name="MessDetectorOptionsConfiguration">
|
||||||
<option name="transferred" value="true" />
|
<option name="transferred" value="true" />
|
||||||
</component>
|
</component>
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,25 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
filename="report_dummie.docx"
|
|
||||||
weeks_ago="0"
|
weeks_ago="0"
|
||||||
report_date="2022-12-12"
|
|
||||||
|
|
||||||
# Parse de command line argumenten
|
# Parse command line arguments
|
||||||
while [ "$#" -gt 0 ]; do
|
for arg in "$@"; do
|
||||||
case "$1" in
|
case $arg in
|
||||||
--weeks_ago=*)
|
--weeks_ago=*)
|
||||||
weeks_ago="${1#*=}"
|
weeks_ago="${arg#*=}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Onbekende optie: $1"
|
echo "Unknown option: $arg"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
shift
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Controleer of de vereiste argumenten zijn ingesteld
|
# Check if required arguments are set
|
||||||
if [ -z "$weeks_ago" ]; then
|
if [ -z "$weeks_ago" ]; then
|
||||||
echo "Missende argumenten. Gebruik: build_mosiac.sh --weeks_ago=3"
|
echo "Missing arguments. Use: build_mosiac.sh --weeks_ago=3"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
cd ../r_app
|
||||||
echo "Weeks ago: $weeks_ago"
|
Rscript 2_CI_data_prep.R $weeks_ago
|
||||||
cd /Users/mfolkerts/smartCane/r_app
|
|
||||||
Rscript 2_CI_data_prep.R $weeks_ago
|
|
||||||
|
|
@ -1,51 +1,37 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
filename="report_dummie.docx"
|
# Parse command line arguments
|
||||||
weeks_ago="0"
|
for arg in "$@"; do
|
||||||
report_date="2022-12-12"
|
case $arg in
|
||||||
|
|
||||||
# Parse de command line argumenten
|
|
||||||
while [ "$#" -gt 0 ]; do
|
|
||||||
case "$1" in
|
|
||||||
--filename=*)
|
--filename=*)
|
||||||
filename="${1#*=}"
|
filename="${arg#*=}"
|
||||||
;;
|
;;
|
||||||
--weeks_ago=*)
|
--weeks_ago=*)
|
||||||
weeks_ago="${1#*=}"
|
weeks_ago="${arg#*=}"
|
||||||
;;
|
;;
|
||||||
--report_date=*)
|
--report_date=*)
|
||||||
report_date="${1#*=}"
|
report_date="${arg#*=}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Onbekende optie: $1"
|
echo "Unknown option: $arg"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
shift
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Controleer of de vereiste argumenten zijn ingesteld
|
# Check if required arguments are set
|
||||||
if [ -z "$filename" ] || [ -z "$weeks_ago" ] || [ -z $report_date ]; then
|
if [ -z "$filename" ] || [ -z "$weeks_ago" ] || [ -z "$report_date" ]; then
|
||||||
echo "Missende argumenten. Gebruik: build_reports.sh --filename=hello.txt --weeks_ago=3 --report_date=2020-01-01"
|
echo "Missing arguments. Use: build_reports.sh --filename=hello.txt --weeks_ago=3 --report_date=2020-01-01"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Je script logica hier
|
# Script logic here
|
||||||
echo "Filename: $filename"
|
echo "Filename: $filename"
|
||||||
echo "Weeks ago: $weeks_ago"
|
echo "Weeks ago: $weeks_ago"
|
||||||
echo "Report date: $report_date"
|
echo "Report date: $report_date"
|
||||||
|
|
||||||
#script_dir="$(dirname "$0")"
|
|
||||||
#echo $script_dir;
|
|
||||||
#/bin/ps aux | grep fontd
|
|
||||||
#output_file="/Users/mfolkerts/smartCane/laravel_app/storage/app/chemba/$filename"
|
|
||||||
|
|
||||||
#echo "Output file: $output_file"
|
|
||||||
echo '\n'
|
echo '\n'
|
||||||
|
|
||||||
echo 'zx28tb' | /usr/bin/sudo -S launchctl load -w /System/Library/LaunchAgents/com.apple.fontd.useragent.plist
|
echo 'zx28tb' | /usr/bin/sudo -S launchctl load -w /System/Library/LaunchAgents/com.apple.fontd.useragent.plist
|
||||||
cd /Users/mfolkerts/smartCane/r_app
|
cd /Users/mfolkerts/smartCane/r_app
|
||||||
#Rscript -e "rmarkdown::render('/Users/mfolkerts/smartCane/r_app/CI_Report_dashboard_planet.Rmd', 'all')"
|
Rscript -e "rmarkdown::render('CI_report_dashboard_planet.Rmd', output_file='$filename', params=list(ref='$ref', report_date='$report_date'))"
|
||||||
#Rscript 1_harvest_data_EcoFarm_v2.R
|
|
||||||
#Rscript 2_CI_data_prep.R $weeks_ago
|
|
||||||
Rscript -e "rmarkdown::render('CI_report_dashboard_planet.Rmd', output_file='$filename', params=list(ref='$ref', report_date='$report_date'))"
|
|
||||||
|
|
@ -6,10 +6,8 @@
|
||||||
use App\Models\ProjectDownload;
|
use App\Models\ProjectDownload;
|
||||||
use Illuminate\Bus\Batchable;
|
use Illuminate\Bus\Batchable;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Process\Exceptions\ProcessFailedException;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
|
@ -37,42 +35,32 @@ public function __construct(ProjectDownload $download, Carbon $date,)
|
||||||
*/
|
*/
|
||||||
public function handle(): void
|
public function handle(): void
|
||||||
{
|
{
|
||||||
$projectFolder = base_path('../');
|
|
||||||
|
|
||||||
$command = [
|
$command = [
|
||||||
sprintf('%srunpython.sh', $projectFolder),
|
sprintf('%srunpython.sh', base_path('../')),
|
||||||
sprintf('--date=%s', $this->date->format('Y-m-d')),
|
sprintf('--date=%s', $this->date->format('Y-m-d')),
|
||||||
sprintf('--days=%d', $this->days),
|
sprintf('--days=%d', $this->days),
|
||||||
sprintf('--project_dir=%s', $this->download->project->download_path),
|
sprintf('--project_dir=%s', $this->download->project->download_path),
|
||||||
];
|
];
|
||||||
|
|
||||||
// Convert commands array to a single string
|
|
||||||
|
|
||||||
$process = new Process($command);
|
$process = new Process($command);
|
||||||
$process->setTimeout(3600); // stel een geschikte timeout in
|
$process->setTimeout(3600);
|
||||||
$process->start();
|
$process->run();
|
||||||
|
|
||||||
try {
|
if (!$process->isSuccessful()) {
|
||||||
$process->wait(function ($type, $buffer) use (&$myOutput) {
|
logger('error', $process->getErrorOutput());
|
||||||
logger($buffer);
|
|
||||||
});
|
|
||||||
} catch (ProcessFailedException $exception) {
|
|
||||||
logger('error', $exception->getMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->download->update([
|
$this->download->update(['status' => 'completed']);
|
||||||
'status' => 'completed',
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function handleForDate(Project $project, Carbon $date)
|
public static function handleForDate(Project $project, Carbon $date)
|
||||||
{
|
{
|
||||||
$filename = sprintf('%s.tif', $date->format('Y-m-d'));
|
$filename = $date->format('Y-m-d') . '.tif';
|
||||||
if ($project->downloads()->where(['status' => 'completed', 'name' => $filename])->count() > 0) {
|
if ($project->downloads()->where(['status' => 'completed', 'name' => $filename])->count() > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = sprintf('%s/%s/%s', $project->download_path, 'merged_final_tif', $filename);
|
$path = $project->download_path . '/merged_final_tif/' . $filename;
|
||||||
return new self(
|
return new self(
|
||||||
$project->downloads()->create([
|
$project->downloads()->create([
|
||||||
'name' => $filename,
|
'name' => $filename,
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ public function handle(): void
|
||||||
|
|
||||||
$process = new Process($command);
|
$process = new Process($command);
|
||||||
$process->setTimeout(120);
|
$process->setTimeout(120);
|
||||||
$currentPath = '/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin/Users/mfolkerts/anaconda3/bin:/Library/Apple/usr/bin';
|
$currentPath = 'usr/bin:/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin/Users/mfolkerts/anaconda3/bin:/Library/Apple/usr/bin';
|
||||||
|
|
||||||
$process->setEnv(['PATH' => $currentPath.':/usr/local/Cellar/pandoc/3.1.8/bin/pandoc']);
|
$process->setEnv(['PATH' => $currentPath.':/usr/local/Cellar/pandoc/3.1.8/bin/pandoc']);
|
||||||
// $process->setTimeout(36000); // stel een geschikte timeout in
|
// $process->setTimeout(36000); // stel een geschikte timeout in
|
||||||
|
|
|
||||||
|
|
@ -82,8 +82,6 @@ message("starting ", file)
|
||||||
# names(CI) <- c("green","nir")
|
# names(CI) <- c("green","nir")
|
||||||
message("raster loaded")
|
message("raster loaded")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CI <- CI[[2]]/CI[[1]]-1
|
CI <- CI[[2]]/CI[[1]]-1
|
||||||
# CI <- CI$nir/CI$green-1
|
# CI <- CI$nir/CI$green-1
|
||||||
message("CI calculated")
|
message("CI calculated")
|
||||||
|
|
@ -100,7 +98,6 @@ message("CI calculated")
|
||||||
|
|
||||||
# v_crop <- mask_raster(v, pivot_sf_q)
|
# v_crop <- mask_raster(v, pivot_sf_q)
|
||||||
return(CI)
|
return(CI)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# rasters_masked <- map(filtered_files, create_mask_and_crop, pivot_sf_q)
|
# rasters_masked <- map(filtered_files, create_mask_and_crop, pivot_sf_q)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue