Instead of using args.<destination> as variables, make those variables explicit and call them directly.
Example:
|
args = parser.parse_args() |
|
print(args) |
|
|
|
# Convert the date/time to a formatted string |
|
t = args.start.strftime("%Y%m%dT%H%MZ") |
|
print(args.mask, args.file, t) |
|
|
|
# If necessary replace ERA5 land/surface fields with higher-resolution options |
|
if "era5land" in args.type: |
|
replace_landsurface_with_ERA5land_IC.swap_land_era5land(args.mask, args.file, t) |
|
shutil.move(args.file.as_posix(), args.file.as_posix().replace('.tmp', '')) |
can be changed to:
- args = parser.parse_args()
+ mask, replacement_file, start, type = parser.parse_args()
print(args)
# Convert the date/time to a formatted string
- t = args.start.strftime("%Y%m%dT%H%MZ")
+ t = start.strftime("%Y%m%dT%H%MZ")
- print(args.mask, args.file, t)
+ print(mask, replacement_file, t)
# If necessary replace ERA5 land/surface fields with higher-resolution options
- if "era5land" in args.type:
+ if "era5land" in type:
- replace_landsurface_with_ERA5land_IC.swap_land_era5land(args.mask, args.file, t)
+ replace_landsurface_with_ERA5land_IC.swap_land_era5land(mask, replacement_file, t)
- shutil.move(args.file.as_posix(), args.file.as_posix().replace('.tmp', ''))
+ shutil.move(replacement_file.as_posix(), replacement_file.as_posix().replace('.tmp', ''))
This simplifies the code and avoids accessing attribute multiple times (anytime args.<destination> gets called is an attribute access).
Instead of using
args.<destination>as variables, make those variables explicit and call them directly.Example:
replace_landsurface/src/hres_ic.py
Lines 51 to 61 in 2dcc1d7
can be changed to:
This simplifies the code and avoids accessing attribute multiple times (anytime
args.<destination>gets called is an attribute access).