diff --git a/docs/source/conf.py b/docs/source/conf.py index 4aa90f8..f825969 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -14,6 +14,7 @@ import os import sys sys.path.insert(0, os.path.abspath('../../kaipy')) sys.path.insert(1, os.path.abspath('../../kaipy/scripts/quicklook')) +sys.path.insert(2, os.path.abspath('../../kaipy/scripts/preproc')) # -- Project information ----------------------------------------------------- diff --git a/docs/source/scripts.rst b/docs/source/scripts.rst index 64942e4..7810dfe 100644 --- a/docs/source/scripts.rst +++ b/docs/source/scripts.rst @@ -59,6 +59,31 @@ The quicklook directory has scripts that are used to quickly look at the data. T .. autoprogram:: vizTrj:create_command_line_parser() :prog: vizTrj.py +Preprocessing +------------- +The preprocessing directory has scripts that are used to setup MAGE simulations including grid generation and solar wind input file. The scripts are: + +.. autoprogram:: cda2wind:create_command_line_parser() + :prog: cda2wind.py + +.. autoprogram:: genLFM:create_command_line_parser() + :prog: genLFM.py + +.. autoprogram:: genRCM:create_command_line_parser() + :prog: genRCM.py + +.. .. autoprogram:: INIGenerator:parse_args() +.. :prog: INIGenerator.py + +.. .. autoprogram:: wsa2gamera:parser +.. :prog: wsa2gamera.py + +.. .. autoprogram:: wsa2TDgamera:create_command_line_parser() +.. :prog: wsa2TDgamera.py + +.. autoprogram:: XMLGenerator:create_command_line_parser() + :prog: XMLGenerator.py + diff --git a/kaipy/scripts/preproc/XMLGenerator.py b/kaipy/scripts/preproc/XMLGenerator.py index 2fbb7d5..aed838c 100755 --- a/kaipy/scripts/preproc/XMLGenerator.py +++ b/kaipy/scripts/preproc/XMLGenerator.py @@ -347,10 +347,15 @@ def create_xml_template(ini_file, xml_file): print("\n\nTemplate creation complete!\n\n") +def create_command_line_parser(): + """Create the command-line argument parser. -if __name__ == "__main__": - """Convert a .ini file to a .xml file.""" + Create the parser for command-line arguments. + Returns: + argparse.ArgumentParser: Command-line argument parser for this script. + """ + #Defaults # Create the command-line argument parser. parser = argparse.ArgumentParser(description="Convert Kaiju .ini files to XML configuration or XML configuration template files.") parser.add_argument("-t", dest="template", help="Path to .xml file as source template") @@ -359,6 +364,13 @@ if __name__ == "__main__": parser.add_argument("-d", "--debug", help="Activate debug mode", action="store_true") parser.add_argument("-v", "--verbose", help="Activate verbose execution mode", action="store_true") + return parser + + +if __name__ == "__main__": + """Convert a .ini file to a .xml file.""" + # Set up the command-line parser. + parser = create_command_line_parser() # Parse the commmand-line arguments. args = parser.parse_args() diff --git a/kaipy/scripts/preproc/cda2wind.py b/kaipy/scripts/preproc/cda2wind.py index 8027e71..a1c876f 100755 --- a/kaipy/scripts/preproc/cda2wind.py +++ b/kaipy/scripts/preproc/cda2wind.py @@ -91,7 +91,13 @@ def getPrevDayF107(t0): return prevF107 -if __name__ == "__main__": +def create_command_line_parser(): + """Create the command-line argument parser. + + Returns: + argparse.ArgumentParser: Command-line argument parser for this script. + """ + #Defaults fOut = "bcwind.h5" mod = "LFM" t0Str="2010-01-01T00:00:00" @@ -105,8 +111,7 @@ if __name__ == "__main__": doEps = False #Usually f107 above 300 is not reliable. The daily value could be distorted by flare emissions even if the flare may only last a short time during a day. - maxf107 = 300.0 - minMfast = 1.5 + MainS = """ This script does several things: 1. Fetch OMNI data from CDAWeb between the specified times (must be at least 2 hours in length) @@ -140,6 +145,14 @@ if __name__ == "__main__": parser.add_argument('-f107', type=float,default=None,help="Set f10.7 value to use in bcwind file. Only used if no data available. (default: %(default)s)") parser.add_argument('-kp', type=float,default=None,help="Set Kp value to use in bcwind file. Only used if no data available. (default: %(default)s)") parser.add_argument('-safe', action='store_true',default=False,help="Run in SAFE mode. Does not create the h5 file if certain conditions are not met (default: %(default)s)") + + return parser + +if __name__ == "__main__": + #Defaults + maxf107 = 300.0 + minMfast = 1.5 + parser = create_command_line_parser() #Finalize parsing args = parser.parse_args() diff --git a/kaipy/scripts/preproc/genLFM.py b/kaipy/scripts/preproc/genLFM.py index a555688..01ea1ff 100755 --- a/kaipy/scripts/preproc/genLFM.py +++ b/kaipy/scripts/preproc/genLFM.py @@ -17,21 +17,21 @@ rParams = { #"H": '' +def create_command_line_parser(): + """Create the command-line argument parser. -if __name__ == "__main__": + Create the parser for command-line arguments. + + Returns: + argparse.ArgumentParser: Command-line argument parser for this script. + """ + #Defaults -#Arg parsing - Nc0 = 8 #Number of outer i cells to cut out from LFM grid (OCT) - fIn = "./lfmG" - doEpsY = True - TINY = 1.0e-8 Rin = 2.0 Rout = 0.0 #List of grids gStrs = ['D','Q','O','H'] - gLabs = ["Double","Quad","Oct","Hex"] - Nij0 = 48 - Nk0 = 64 + MainS = """Generates LFM-style HDF5 grid for Gamera Grid types (gid) @@ -49,6 +49,21 @@ if __name__ == "__main__": parser.add_argument('-Rout',type=float,metavar="Rout",default=Rout ,help="Sunward outer radius (default: %(default)s)") parser.add_argument('-vizG', action='store_true', default=False,help="Show 2D figure w/ ghosts (default: %(default)s)") + return parser + + +if __name__ == "__main__": + #Defaults asdf + Nc0 = 8 #Number of outer i cells to cut out from LFM grid (OCT) + fIn = "./lfmG" + doEpsY = True + TINY = 1.0e-8 + gLabs = ["Double","Quad","Oct","Hex"] + gStrs = ['D','Q','O','H'] + Nij0 = 48 + Nk0 = 64 + # Set up the command-line parser. + parser = create_command_line_parser() #Finalize parsing args = parser.parse_args() gid = args.gid diff --git a/kaipy/scripts/preproc/genRCM.py b/kaipy/scripts/preproc/genRCM.py index 6e5ad68..59539f7 100755 --- a/kaipy/scripts/preproc/genRCM.py +++ b/kaipy/scripts/preproc/genRCM.py @@ -23,10 +23,15 @@ PFLAV = 2 EFUDGE = 1./3. PFUDGE = 0.0 +def create_command_line_parser(): + """Create the command-line argument parser. -if __name__ == "__main__": + Create the parser for command-line arguments. - #Arg parsing + Returns: + argparse.ArgumentParser: Command-line argument parser for this script. + """ + #Defaults fOut = "rcmconfig.h5" num_e = 39 num_p = 120 @@ -61,7 +66,12 @@ if __name__ == "__main__": parser.add_argument('-maxKp', type=int,default=maxKp, help="Max. Kp index allowed in the electron wave model, integer only (default: %(default)s)") parser.add_argument('-i', type=str,default=fOut,metavar="fIn", help="Input file name when addWM is true (default: %(default)s)") + return parser +if __name__ == "__main__": + + # Set up the command-line parser. + parser = create_command_line_parser() #Finalize parsing args = parser.parse_args() fOut = args.o diff --git a/requirements.txt b/requirements.txt index e8eaa69..876a6e5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ alive_progress astropy -#cartopy +cartopy cdasws configparser h5py