This commit is contained in:
Martin Folkerts 2024-01-22 09:54:15 +01:00
parent d3c2c18918
commit 2c84747ff0
4 changed files with 32 additions and 15 deletions

View file

@ -43,6 +43,7 @@ public function handle(): void
sprintf('%srunpython.sh', $projectFolder),
sprintf('--date=%s', $this->date->format('Y-m-d')),
sprintf('--days=%d', $this->days),
sprintf('--project_dir=%s', $this->download->project->download_path),
];
// Convert commands array to a single string

View file

@ -14,4 +14,9 @@ class ProjectDownload extends Model
'path',
'status',
];
public function project(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Project::class);
}
}

View file

@ -73,10 +73,22 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 13,
"id": "244b5752-4f02-4347-9278-f6a0a46b88f4",
"metadata": {},
"outputs": [],
"outputs": [
{
"ename": "NameError",
"evalue": "name 'Path' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[13], line 101\u001b[0m\n\u001b[1;32m 41\u001b[0m evalscript_true_color \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\"\"\u001b[39m\n\u001b[1;32m 42\u001b[0m \u001b[38;5;124m //VERSION=3\u001b[39m\n\u001b[1;32m 43\u001b[0m \n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 79\u001b[0m \u001b[38;5;124m }\u001b[39m\n\u001b[1;32m 80\u001b[0m \u001b[38;5;124m\"\"\"\u001b[39m\n\u001b[1;32m 82\u001b[0m \u001b[38;5;66;03m#def get_true_color_request(time_interval):\u001b[39;00m\n\u001b[1;32m 83\u001b[0m \u001b[38;5;66;03m# return SentinelHubRequest(\u001b[39;00m\n\u001b[1;32m 84\u001b[0m \u001b[38;5;66;03m# evalscript=evalscript_true_color,\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 98\u001b[0m \u001b[38;5;66;03m#\u001b[39;00m\n\u001b[1;32m 99\u001b[0m \u001b[38;5;66;03m# )\u001b[39;00m\n\u001b[0;32m--> 101\u001b[0m BASE_PATH_SINGLE \u001b[38;5;241m=\u001b[39m Path(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m../laravel_app/storage/app/chemba/\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m 102\u001b[0m BASE_PATH_SINGLE_IMAGES \u001b[38;5;241m=\u001b[39m Path(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m../laravel_app/storage/app/chemba/single_images\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m 103\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mget_true_color_request_day_east\u001b[39m(time_interval):\n\u001b[1;32m 104\u001b[0m \u001b[38;5;66;03m#base_path = '../laravel_app/storage/app/chemba/single_images/'\u001b[39;00m\n",
"\u001b[0;31mNameError\u001b[0m: name 'Path' is not defined"
]
}
],
"source": [
"\"\"\"\n",
"Utilities used by example notebooks\n",
@ -177,10 +189,10 @@
"# data_folder='chemba_single_images/'+date,\n",
"#\n",
"# )\n",
"BASE_PATH_SINGLE_IMAGES = Path('../laravel_app/storage/app/chemba/single_images')\n",
"\n",
"BASE_PATH = Path('../laravel_app/storage/app') / os.getenv('PROJECT_DIR','chemba') \n",
"BASE_PATH_SINGLE_IMAGES = Path(BASE_PATH / 'single_images')\n",
"def get_true_color_request_day_east(time_interval):\n",
" base_path = '../laravel_app/storage/app/chemba/single_images/'\n",
" \n",
" return SentinelHubRequest(\n",
" evalscript=evalscript_true_color,\n",
" input_data=[\n",
@ -200,7 +212,6 @@
" )\n",
"\n",
"def get_true_color_request_day_west(time_interval):\n",
" base_path = '../laravel_app/storage/app/chemba/single_images/'\n",
" return SentinelHubRequest(\n",
" evalscript=evalscript_true_color,\n",
" input_data=[\n",
@ -408,13 +419,13 @@
" time.sleep(.5)\n",
"\n",
"def merge_files(slot):\n",
" base_path = Path('../laravel_app/storage/app/chemba')\n",
" \n",
" # List the downloaded Tiffs in the different subfolders with pathlib (native library)\n",
" file_list = [f\"{x}/response.tiff\" for x in Path(base_path / 'single_images' / slot).iterdir()]\n",
" file_list = [f\"{x}/response.tiff\" for x in Path(BASE_PATH_SINGLE_IMAGES / slot).iterdir()]\n",
" print(file_list)\n",
"\n",
" folder_for_merged_tifs = str(base_path / 'merged_tif' / f\"{slot}.tif\")\n",
" folder_for_virtual_raster = str(base_path / 'merged_virtual' / f\"merged{slot}.vrt\")\n",
" folder_for_merged_tifs = str(BASE_PATH / 'merged_tif' / f\"{slot}.tif\")\n",
" folder_for_virtual_raster = str(BASE_PATH / 'merged_virtual' / f\"merged{slot}.vrt\")\n",
"\n",
" # Create a virtual raster\n",
" vrt_all = gdal.BuildVRT(folder_for_virtual_raster, file_list)\n",
@ -553,8 +564,8 @@
"import shutil\n",
" \n",
"# List of folder names\n",
"base_path = Path('../laravel_app/storage/app/chemba')\n",
"folders_to_empty = [str(base_path / 'merged_virtual'), str(base_path / 'single_images')]\n",
"\n",
"folders_to_empty = [BASE_PATH / 'merged_virtual', BASE_PATH_SINGLE_IMAGES]\n",
" \n",
"# Function to empty folders\n",
"\n",

View file

@ -2,8 +2,7 @@
date=$(date +%Y-%m-%d)
# Standaardwaarde voor days
days=1
project_dir="chemba"
project_dir="chemba_1"
# Loop door alle argumenten
while [ "$#" -gt 0 ]; do
@ -28,6 +27,7 @@ done
# Gebruik de variabele in je script
echo "Datum: $date"
echo "Aantal dagen: $days"
echo "Project directory: $project_dir"
# Activeer de virtuele omgeving
script_dir="$(dirname "$0")"
@ -35,7 +35,7 @@ source "$script_dir/python_app/myenv/bin/activate"
export DAYS=$days
export DATE=$date
export ProjectDir=$project_dir
export PROJECT_DIR=$project_dir
# Hier kan je verdere stappen toevoegen, zoals het uitvoeren van je Python-script of Jupyter Notebook
jupyter nbconvert --execute --to script --stdout "$script_dir/python_app/Chemba_download.ipynb"