Batch TSF_process and TSF_seas2img from TIMESAT
Last active
March 9, 2024 15:14
-
-
Save bennyistanto/66384ba8f33901ec65a0313b9197ec1f to your computer and use it in GitHub Desktop.
Batch TSF_seas2img from TIMESAT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal enabledelayedexpansion | |
:: Paths | |
set TOOL_PATH=C:\timesat33\timesat_fortran\tools\TSF_seas2img.exe | |
set INPUT_PATH=C:\timesat33\compiled\Win64\2y | |
set OUTPUT_PATH=X:\Temp\modis\lbn\gee\11_timesat_raw\bil\2y | |
:: Loop through the years | |
for /L %%i in (2002,1,2023) do ( | |
set /a year2=%%i+1 | |
:: For sos and 24,46 | |
%TOOL_PATH% "!INPUT_PATH!\lbn_2y_%%i_!year2!_gee_raw_TS.tpa" 1 24 46 -1 -2 "!OUTPUT_PATH!\lbn_2y_end_%%i_sos" 2 | |
:: For eos and 24,46 | |
%TOOL_PATH% "!INPUT_PATH!\lbn_2y_%%i_!year2!_gee_raw_TS.tpa" 2 24 46 -1 -2 "!OUTPUT_PATH!\lbn_2y_end_%%i_eos" 2 | |
:: For sos and 47,69 | |
%TOOL_PATH% "!INPUT_PATH!\lbn_2y_%%i_!year2!_gee_raw_TS.tpa" 1 47 69 -1 -2 "!OUTPUT_PATH!\lbn_2y_start_!year2!_sos" 2 | |
:: For eos and 47,69 | |
%TOOL_PATH% "!INPUT_PATH!\lbn_2y_%%i_!year2!_gee_raw_TS.tpa" 2 47 69 -1 -2 "!OUTPUT_PATH!\lbn_2y_start_!year2!_eos" 2 | |
) | |
echo All done! | |
endlocal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal enabledelayedexpansion | |
:: Paths | |
set TOOL_PATH=C:\timesat33\timesat_fortran\tools\TSF_seas2img.exe | |
set INPUT_PATH=C:\timesat33\compiled\Win64 | |
set OUTPUT_PATH=X:\Temp\modis\lbn\gee\11_timesat_raw\bil\3y | |
:: Loop through the years | |
for /L %%i in (2003,1,2023) do ( | |
:: For sos and 47,92 | |
%TOOL_PATH% "!INPUT_PATH!\lbn_3y_%%i_gee_raw_TS.tpa" 1 47 92 -1 -2 "!OUTPUT_PATH!\lbn_pheno_8d_%%i_sos" 2 | |
:: For eos and 47,92 | |
%TOOL_PATH% "!INPUT_PATH!\lbn_3y_%%i_gee_raw_TS.tpa" 2 47 92 -1 -2 "!OUTPUT_PATH!\lbn_pheno_8d_%%i_eos" 2 | |
) | |
echo All done! | |
endlocal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal enabledelayedexpansion | |
:: Set paths | |
set TOOL_PATH=C:\timesat33\timesat_fortran\main\TSF_process.exe | |
set INPUT_DIR=C:\timesat33\compiled\Win64\2y | |
set NO_OF_PROCESSORS=1 | |
:: Loop through each .set file in the directory | |
for %%f in (%INPUT_DIR%\*.set) do ( | |
echo Processing: %%f | |
%TOOL_PATH% "%%f" %NO_OF_PROCESSORS% | |
) | |
echo All .set files processed! | |
endlocal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal enabledelayedexpansion | |
:: Set paths | |
set TOOL_PATH=C:\timesat33\timesat_fortran\main\TSF_process.exe | |
set INPUT_DIR=C:\timesat33\compiled\Win64\3y | |
set NO_OF_PROCESSORS=1 | |
:: Loop through each .set file in the directory | |
for %%f in (%INPUT_DIR%\*.set) do ( | |
echo Processing: %%f | |
%TOOL_PATH% "%%f" %NO_OF_PROCESSORS% | |
) | |
echo All .set files processed! | |
endlocal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal enabledelayedexpansion | |
:: Set paths | |
set TOOL_PATH=C:\timesat33\timesat_fortran\main\TSF_process.exe | |
set MERGE_TOOL_PATH=C:\timesat33\timesat_fortran\tools\TSF_merge.exe | |
set INPUT_DIR=C:\timesat33\compiled\Win64\3y | |
set BATCH_FILE_DIR=C:\timesat33\compiled\Win64 | |
:: Hardcoded number of processors for multi-core processing | |
set NO_OF_PROCESSORS=10 | |
:: Save the current PATH to restore later | |
set "original_path=%PATH%" | |
:: Add the directory of TSF_process.exe and TSF_merge to the PATH environment variable | |
set PATH=%PATH%;C:\timesat33\timesat_fortran\main;C:\timesat33\timesat_fortran\tools | |
:: Verify that the TOOL_PATH, MERGE_TOOL_PATH and INPUT_DIR exist | |
if not exist "%TOOL_PATH%" ( | |
echo Error: TOOL_PATH "%TOOL_PATH%" does not exist. | |
goto end | |
) | |
if not exist "%MERGE_TOOL_PATH%" ( | |
echo Error: MERGE_TOOL_PATH "%MERGE_TOOL_PATH%" does not exist. | |
goto end | |
) | |
if not exist "%INPUT_DIR%" ( | |
echo Error: INPUT_DIR "%INPUT_DIR%" does not exist. | |
goto end | |
) | |
:: Loop through each .set file in the INPUT_DIR, excluding processed .set files | |
for /f "delims=" %%f in ('dir /b /a-d "%INPUT_DIR%\*.set" ^| findstr /v /i "_set[0-9]*.set"') do ( | |
set "full_path=%%f" | |
set "file_path=%INPUT_DIR%\!full_path!" | |
echo Processing: !file_path! | |
:: Execute the TSF_process in parallel mode and specify the number of processors | |
"!TOOL_PATH!" "!file_path!" %NO_OF_PROCESSORS% parallel | |
:: Extract the filename without extension to identify the generated .bat file | |
set "base_name=%%~nf" | |
:: Construct the expected batch file name in the BATCH_FILE_DIR | |
set "expected_batch_file=%BATCH_FILE_DIR%\!base_name!_script.bat" | |
:: Wait for a moment to ensure the .bat file is generated | |
timeout /t 5 /nobreak > NUL | |
:: Check if the generated .bat file exists and execute it | |
if exist "!expected_batch_file!" ( | |
echo Running generated batch file for parallel processing: !expected_batch_file! | |
call "!expected_batch_file!" | |
) else ( | |
echo Warning: Expected batch file for parallel processing "!expected_batch_file!" not found. | |
) | |
) | |
echo All .set files processed! | |
:: Restore the original PATH environment variable | |
set PATH=%original_path% | |
:end | |
endlocal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment