@@ -57,6 +57,7 @@ def parse_arguments():
57
57
58
58
# Return arguments
59
59
return args_parsed
60
+
60
61
def validate_arguments (include_list , exclude_list , prognostic ):
61
62
"""
62
63
Checks that the inclusion and exclusion lists are not provided simultaneously
@@ -82,15 +83,13 @@ def validate_arguments(include_list, exclude_list, prognostic):
82
83
if prognostic and (include_list or exclude_list ):
83
84
raise Exception ("Error: -p incompatible with explicit list of variables" )
84
85
85
-
86
86
def void_validation (* args , ** kwargs ):
87
87
"""
88
88
Don't perform the validation, but print a message to inform that validation has been skipped.
89
89
"""
90
90
print ('Skipping mule validation. To enable the validation, run using the "--validate" option.' )
91
91
return
92
92
93
-
94
93
def initialize_output_file (ff ):
95
94
"""
96
95
Initialize the output UM file by copying the input file and preparing it for output.
@@ -174,7 +173,6 @@ def filter_fields(input_file, prognostic, include_list, exclude_list):
174
173
175
174
return filtered_fields
176
175
177
-
178
176
def check_packed_fields (filtered_fields ):
179
177
"""
180
178
Checks if packed fields in the input file require a land-sea mask and modifies
@@ -243,32 +241,31 @@ def append_fields(outfile, filtered_fields):
243
241
# Ad to the outfile fields
244
242
outfile .fields .append (field .copy ())
245
243
246
-
247
244
def main ():
248
245
249
- # Parse the inputs and validate that they do not xlist or vlist are given.
246
+ # Parse the inputs and validates that either xlist or vlist are given.
250
247
args = parse_arguments ()
251
248
validate_arguments (args .include_list , args .exclude_list , args .prognostic )
252
249
253
- # Skip the mule validation if the "--validate" option is provided.
250
+ # Skips the mule validation if the "--validate" option is provided.
254
251
if args .validate :
255
252
mule .DumpFile .validate = void_validation
256
253
257
254
ff = mule .DumpFile .from_file (args .ifile )
258
255
259
- # Create the output UM file that will be saved.
256
+ # Initializes the output UM file that will be saved.
260
257
outfile = initialize_output_file (ff )
261
258
262
- # Create the output filename.
259
+ # Create the new output filename if one isn't already given .
263
260
output_filename = create_default_outname (args .ifile ) if args .output_path is None else args .output_path
264
261
265
- #Create list of fields that meet all the user defined conditions
262
+ #Create list of fields that meet all the user defined conditions to either include or exclude
266
263
filtered_fields = filter_fields (ff , args .prognostic , args .include_list , args .exclude_list )
267
264
268
- # Find the fields, if any, that needs a land-sea mask .
265
+ # Checks if any of the choosen fields need a land-sea mas and adds it if so .
269
266
filtered_fields = check_packed_fields (filtered_fields )
270
267
271
- # Loop over all the fields.
268
+ # Loops over all the fields.
272
269
append_fields (outfile , filtered_fields )
273
270
274
271
outfile .to_file (output_filename )
0 commit comments