I'm a student dealing with this weird old program that takes only files as input and outputs directly to terminal.
I have a python script, that makes this input file, and writes the output to a text file. However, on each run I have to change the variables manually in the python script myself. There are five instances of variables, that are all in a constant format. Is there a waY I can loop/array this?
My python script :
from subprocess import check_output
#time is in UTC format, ie. IST -5.30 hrs
with open("INPUT", 'w') as f_in: #INPUT is the input file
f_in.write("&INPUT\n")
f_in.write("WLINF = 0.250\n") #lower frequency value
f_in.write("WLSUP = 4.0\n") #highest frequency value
f_in.write("WLINC = 0.5\n") #wavelength increment
f_in.write("IDAY = 289\n") #computing for a specific day
f_in.write("ALAT = 23.0329\n") #latitude of the location
f_in.write("ALON = 72.5517\n") #longitude of the location
f_in.write("IDATM = 3\n") #atmopsheric model 2 - mid latitude summer
f_in.write("ISALB = 5\n") #surface albedo feature
f_in.write("IAER = 5\n") #boundary layer aerosol type selection - 5 - user defined spectral dependance of BLA
f_in.write("WLBAER = .500,.675,.870,.936,1.02\n") #wavelenght points for IAER
f_in.write("WBAER = 5*0.9\n") #single scattering albedo
f_in.write("GBAER = 5*0.8\n") #assymetric factor used with IAER
f_in.write("TIME = 3\n") #Time in IST format (-5.30hr)
f_in.write("QBAER = 0.553,0.258,0.344,0.31,0.276\n") #extinction efficiency percentage
f_in.write("ZOUT = 0.0,15.0\n") #TOA defining
f_in.write("/\n")
check_output('slarrt >> output1.csv',shell=True) #slarrt is the program, and ouytput.csv is the output file
This script
Takes these values that need to be input, writes them to the input file, runs the other program(that takes the inputs from input file), and writes the output to a csv file. then i change the values in the script.
The variables ALAT, ALON, and QBAER and TIME need to be changed on each run, and the values are in an excel sheet. Is there anyway I can do them in one shot? SO FAR, I have been editing each line manually.
Hre is what the data looks like