Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Refactor PyHelp weather inputs and write documentation #12

Merged
merged 52 commits into from
Oct 18, 2018

Conversation

jnsebgosselin
Copy link
Member

@jnsebgosselin jnsebgosselin commented Oct 17, 2018

Fixes #11

The goal of this PR is to allow the use of PyHelp with weather data from any source.

At present, there is no easy way to use precipitation and air temperature data from sources other than the MDDELCC grid. Similarly, there is no easy way to use global solar irradiance data from sources other than the CWEEDS file. PyHelp generate directly the HELP D4, D7, and D13 input files directly from these sources.

This PR proposes to produce the HELP D4, D7, and D13 input files from pre-formatted csv files instead. Therefore, data from any sources can now be used, as long as the data are formatted in the specified format.

The format for the PyHelp weather input files will be the same for the precipitation, average air temperature, and global solar irradiance. An exemple is shown below.

Utilities will still be available to produce these PyHelp weather data input files from the MDDELCC meteo grid and CWEED files, since the code to do that is already available.

weather_input_data

Generate an input PyHelp data file from CWEED files.
Load daily precipitation, average air temperature, or global solar
radiation data from a correctly formatted PyHelp weather input files.
The latitudes, longitudes, dates, and weather data values are stored in
numpy arrays and returned as a dict with, respectively, the keys
'lat', 'lon', 'dates', and 'data'.
This is not going to be needed after the refactoring
@pep8speaks
Copy link

pep8speaks commented Oct 17, 2018

Hello @jnsebgosselin! Thanks for updating the PR.

Line 22:1: E402 module level import not at top of file

Comment last updated on October 18, 2018 at 16:19 Hours UTC

@jnsebgosselin jnsebgosselin self-assigned this Oct 17, 2018
@jnsebgosselin jnsebgosselin added the type: enhancement New feature or request label Oct 17, 2018
@jnsebgosselin jnsebgosselin added this to the 0.1.0 milestone Oct 17, 2018
@jnsebgosselin jnsebgosselin changed the title PR: Refactor how weather input are managed in PyHelp and write documentation PR: Refactor PyHelp weather inputs and write documentation Oct 17, 2018
@jnsebgosselin
Copy link
Member Author

Provided that the PyHhelp weather input files and input grid are already present in the working directory, running PyHelp simply comes down to:

workdir = "C:/Users/User/pyhelp/example"
helpm = HelpManager(workdir, year_range=(2010, 2014))
helpm.build_help_input_files()
output_help = helpm.calc_help_cells('help_example.out', tfsoil=-3)
output_surf = helpm.calc_surf_water_cells(650, 'surf_example.out')

@jnsebgosselin
Copy link
Member Author

jnsebgosselin commented Oct 17, 2018

The PyHelp input files can be generated automatically from the MDDELCC meteo grid and CWEED files with:

workdir = "C:/Users/User/pyhelp/example"
helpm = HelpManager(workdir, year_range=(2010, 2014))

# Generate global solar irradiance input data file.
cweed2_paths = osp.join(workdir, 'CWEEDS', '94792.WY2')
cweed3_paths = osp.join(
    workdir, 'CWEEDS', 'CAN_QC_MONTREAL-INTL-A_7025251_CWEEDS2011_T_N.WY3')
helpm.generate_weather_inputs_from_CWEEDS(cweed2_paths, cweed3_paths)

# Generate precip and avg air temp input data files.
path_to_mddelcc_grid = "F:/MeteoGrilleDaily"
helpm.generate_weather_inputs_from_MDELCC_grid(path_to_mddelcc_grid)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants