A new pathway to update history metadata attribute has been implemented in generate_climos for broader usage of create_climo_files in other programs. As described in the issue, updating the history attribute did not function properly when no argument was passed through terminal standard input since sys.argv was used for command-line reconstruction. This problem is solved by the creation of args dictionary that has keys as options and values as arguments. When sys.argv is empty, the program reconstructs the command-line using the information in the args dictionary. Additionally, create_climo_files function takes the parameter of the Climatological period option(-c/--climo ) for an informative history record.
tmp.py used for testing:
from nchelpers import CFDataset, standard_climo_periods
from dp.generate_climos import create_climo_files
filepath = "./tests/data/tiny_daily_pr.nc"
input_file = CFDataset(filepath)
climo = standard_climo_periods().keys()
for period in input_file.climo_periods.keys() & climo:
t_range = input_file.climo_periods[period]
create_climo_files(
period,
"output",
input_file,
"mean",
*t_range,
)
This PR closes #123
A new pathway to update history metadata attribute has been implemented in
generate_climos
for broader usage ofcreate_climo_files
in other programs. As described in the issue, updating the history attribute did not function properly when no argument was passed through terminal standard input since sys.argv was used for command-line reconstruction. This problem is solved by the creation ofargs
dictionary that has keys as options and values as arguments. When sys.argv is empty, the program reconstructs the command-line using the information in theargs
dictionary. Additionally,create_climo_files
function takes the parameter of the Climatological period option(-c
/--climo
) for an informative history record.tmp.py
used for testing:An example output using the new pathway: