From ad0ddf0d780600d7c80044fa8aa3c6dda7ec19f9 Mon Sep 17 00:00:00 2001 From: Pratik Chakraborty <62383441+52piecesofpaper@users.noreply.github.com> Date: Wed, 13 Jul 2022 15:04:02 +0200 Subject: [PATCH 1/2] Update Run_py3.py Automates the directory updates on the 'General_Input' excel sheet and other requisite input files for different directory structures of different users. A separate file or 'match-case' maybe further added for Linux environments --- SEBAL/Run_py3.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/SEBAL/Run_py3.py b/SEBAL/Run_py3.py index bab5efc..c14a69a 100644 --- a/SEBAL/Run_py3.py +++ b/SEBAL/Run_py3.py @@ -6,12 +6,36 @@ """ import pysebal_py3 +import os +from openpyxl import load_workbook ##### USER INPUTS ##### For Linux SET THE PATH TO INPUT EXCEL SHEET ##### #inputExcel = r"/mnt/d/PySEBAL_dev/test_data/InputEXCEL_v3_3_7_LIN.xlsx" -##### For Windows SET THE PATH TO INPUT EXCEL SHEET ##### -inputExcel = r"D:\PySEBAL_dev\test_data\InputEXCEL_v3_3_7_WIN.xlsx" + +current_wd = os.getcwd() +dir_back = os.getcwd() + "\\..\\" +os.chdir(dir_back) +pySEBAL_Base_dir = os.getcwd() + +SEBAL_dir = pySEBAL_Base_dir + "\\SEBAL" +os.chdir(SEBAL_dir) + +inputExcel = pySEBAL_Base_dir + "\\test_data\\InputEXCEL_v3_3_7_WIN.xlsx" +input_dir = pySEBAL_Base_dir + "\\test_data\\input\\insat" +output_dir = pySEBAL_Base_dir + "\\test_data\\output" +DEM_dir = pySEBAL_Base_dir + "\\test_data\\input\\dem_dal.tif" + + +workbook = load_workbook(filename=inputExcel) +sheet = workbook['General_Input'] + +sheet["B2"] = input_dir +sheet["C2"] = output_dir +sheet["E2"] = DEM_dir + +workbook.save(filename = inputExcel) + st = 2 # starting row number en = 2 # ending row number From e2769d783db485ac003a860729ee9a9df3cfa92a Mon Sep 17 00:00:00 2001 From: Pratik Chakraborty <62383441+52piecesofpaper@users.noreply.github.com> Date: Wed, 13 Jul 2022 15:21:18 +0200 Subject: [PATCH 2/2] Delete Run_py3.py --- SEBAL/Run_py3.py | 50 ------------------------------------------------ 1 file changed, 50 deletions(-) delete mode 100644 SEBAL/Run_py3.py diff --git a/SEBAL/Run_py3.py b/SEBAL/Run_py3.py deleted file mode 100644 index c14a69a..0000000 --- a/SEBAL/Run_py3.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Created on 03 Dec 2019 - -@author: tih, sajid pareeth -""" - -import pysebal_py3 -import os -from openpyxl import load_workbook -##### USER INPUTS - -##### For Linux SET THE PATH TO INPUT EXCEL SHEET ##### -#inputExcel = r"/mnt/d/PySEBAL_dev/test_data/InputEXCEL_v3_3_7_LIN.xlsx" - -current_wd = os.getcwd() -dir_back = os.getcwd() + "\\..\\" -os.chdir(dir_back) -pySEBAL_Base_dir = os.getcwd() - -SEBAL_dir = pySEBAL_Base_dir + "\\SEBAL" -os.chdir(SEBAL_dir) - -inputExcel = pySEBAL_Base_dir + "\\test_data\\InputEXCEL_v3_3_7_WIN.xlsx" -input_dir = pySEBAL_Base_dir + "\\test_data\\input\\insat" -output_dir = pySEBAL_Base_dir + "\\test_data\\output" -DEM_dir = pySEBAL_Base_dir + "\\test_data\\input\\dem_dal.tif" - - -workbook = load_workbook(filename=inputExcel) -sheet = workbook['General_Input'] - -sheet["B2"] = input_dir -sheet["C2"] = output_dir -sheet["E2"] = DEM_dir - -workbook.save(filename = inputExcel) - -st = 2 # starting row number -en = 2 # ending row number - -####### USER INPUTS FINISH HERE - -for number in range(st, en + 1): - try: - print ('starting line num: %d' % number) - pysebal_py3.SEBALcode(number,inputExcel) - print ('line num: %d done' % number) - except: - print ('SEBAL did not run line %d fully' % number)