Skip to content

Commit

Permalink
add AgERA5 example, test other CRS, add unit conversion
Browse files Browse the repository at this point in the history
* add a configuration file with diffenent gridded dataset, resolution, and CRS
* tested for AgERA5 and multiple projected CRS options
* add unit conversion for pressure hPa
  • Loading branch information
JohnVolk committed Jul 23, 2024
1 parent 9b2316a commit 9d5b98e
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 9 deletions.
32 changes: 23 additions & 9 deletions docs/source/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ file that was built to download gridded data from the CONUS404 dataset:
needed so that the wind speed data can both be scaled to 2 m using the
logarithmic vertical velocity profile, see equation 33 in [Allen2005]_.

.. seealso::
There is another configuration file provided with the example station data
and that version points to the `AgERA5 dataset
<https://gee-community-catalog.org/projects/agera5_datasets/>`__ as opposed
to CONUS404. It also specifies a different coordinate reference system and
resolution for spatial interpolation.

The second section of the configuration file is called **DATA**; this
section is exclusivly for the user to specify the names of the station
and gridded weather data as they are found in the station weather data
Expand Down Expand Up @@ -356,14 +363,21 @@ data to and the local folder to download the same data to.


.. note::
The example data used in this tutorial downloads gridded data from the
`CONUS404 dataset <https://support.climateengine.org/article/117-conus404>`__ which
is hosted by OpenET on Google Earth Engine, it is a public asset and as long as you
have access to Google Earth Engine you should have no issues accessing the data.
The export path that is specified in the tests will be automatically created and
you must have authenticated and initialized Google Earth Engine for Python before
running the tests.

The example data used in this tutorial downloads gridded data from the
`CONUS404 dataset
<https://support.climateengine.org/article/117-conus404>`__ which is hosted
by OpenET on Google Earth Engine, it is a public asset and as long as you
have access to Google Earth Engine you should have no issues accessing the
data. The export path that is specified in the tests will be automatically
created and you must have authenticated and initialized Google Earth Engine
for Python before running the tests.

.. seealso::
There is another configuration file provided with the example station data
and that version points to the `AgERA5 dataset
<https://gee-community-catalog.org/projects/agera5_datasets/>`__ as opposed
to CONUS404. It also specifies a different coordinate reference system and
resolution for spatial interpolation.

.. code:: python3
Expand Down Expand Up @@ -713,7 +727,7 @@ for the grid shapefile generation. Being in the same geographic
coordinate reference system allows for using the grid to be used
for computing zonal statistics. The WGS 84 resampled raster files can be
distinguished from the interpolated files as they do not have
a suffix signifying a coordinate reference system code such as
a suffix signifying a coordinate reference system authority and code such as
“..._ESRI_XXXXX.tif” or “..._EPSG_XXXX.tif”.

Here is a screenshot of the fishnet grid produced eariler in the tutorial
Expand Down
109 changes: 109 additions & 0 deletions gridwxcomp/example_data/gridwxcomp_config_agera5.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
[METADATA]

# Projection information
# gridwxcomp will reproject point data to WGS84 geographic for consistency with
# point data that is downloaded from Google Earth Engine, if the input coordinates
# are not already in WGS84 decimal degrees then specify they are in here using
# an authority and code. The "grid_resolution" parameter refers to an optional fishnet grid
# that can be created by gridwxcomp which is always created in the WGS 84 geographic
# coordinate reference system, hence the resolution is in decimal degrees. gridwxcomp
# can also reproject point data for the generation of a point shapefile containing
# bias results and before performing spatial resolution.
# Finally the interpolated rasters are reprojected back to WGS 84 and resampled once
# more using the output_data_resolution parameter (degrees). The example values
# shown below refer to WGS 84 (EPSG:4326) geographic coordinate system and the
# NAD83 / UTM zone 12N (EPSG:26912) projected coordinate system, and these are the
# default options if the user forgets to specify the parameters in the config file.
input_data_projection = EPSG:4326
grid_resolution = 0.05
interpolation_projection = EPSG:26912
interpolation_resolution = 500
output_data_resolution = 0.05

# Bounding information
# The bounds/extents for the interpolation area in decimal degrees.
xmin = -111.8708332996666428
xmax = -108.57083329966683
ymin = 38.087499999966674
ymax = 40.5874999999666741


# Gridded dataset information
# Specify the Earth Engine image collection you'd like to use for comparison.
# collection_name will be used in the generation of filenames
# You may also specify the start and end dates (Format: YYYY-MM-DD) of the data to download.
# If the dates are left blank then gridwxcomp will generate these values automatically.
# More info on Ag-ERA5 dataset here: https://gee-community-catalog.org/projects/agera5_datasets/
collection_name = agera5
collection_path = projects/climate-engine-pro/assets/ce-ag-era5/daily
start_date =
end_date =


# File structure information
# These values are necessary for gridwxcomp to parse the data files.
# Use 'station' for observed and 'gridded' for any model data
# Anemometer height required in meters
station_anemometer_height = 2
station_lines_of_header = 1
station_missing_data_value = nan
gridded_anemometer_height = 10
gridded_lines_of_header = 1
gridded_missing_data_value = nan

[DATA]
# For the below parameters, enter the name of the column containing the following values
# If a column is not provided, leave the parameter blank.

station_date_col = date
station_tmax_col = TMax (C)
station_tmin_col = TMin (C)
station_rs_col = Rs (w/m2)
station_wind_col = ws_2m (m/s)
station_ea_col =
station_tdew_col = TDew (C)
station_rhmax_col = RHMax (%)
station_rhmin_col = RHMin (%)
station_rhavg_col = RHAvg (%)
station_eto_col = ETo (mm)
station_etr_col = ETr (mm)

gridded_date_col = date
gridded_tmax_col = Temperature_Air_2m_Max_24h
gridded_tmin_col = Temperature_Air_2m_Min_24h
gridded_rs_col = Solar_Radiation_Flux
gridded_wind_col = Wind_Speed_10m_Mean
gridded_ea_col = Vapour_Pressure_Mean
gridded_tdew_col = Dew_Point_Temperature_2m_Mean
gridded_rhmax_col =
gridded_rhmin_col =
gridded_rhavg_col = Relative_Humidity_2m_15h
gridded_eto_col =
gridded_etr_col =

[UNITS]
# For the parameters in this section, enter the corresponding units from the options commented above.

# K, F, C
station_temp_units = C
gridded_temp_units = K

# kw-hr/m2, j/m2, mj/m2, langleys, w/m2
station_solar_units = w/m2
gridded_solar_units = j/m2

# m/s, mph, kmph
station_wind_units = m/s
gridded_wind_units = m/s

# kPa, torr, mbar, hPa
station_ea_units = kpa
gridded_ea_units = hPa

# percent, fraction
station_rh_units = percent
gridded_rh_units = percent

# inches, mm
station_et_units = mm
gridded_et_units = mm
2 changes: 2 additions & 0 deletions gridwxcomp/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ def convert_units(config_dictionary, version, df):
elif units_list[i] == 'ea':
if var_units == 'kpa':
converted_data = np.array(df[var_list[i]])
elif var_units == 'hpa':
converted_data = np.array(df[var_list[i]] * 0.1) # hPa to kPa
elif var_units == 'torr':
converted_data = np.array(df[var_list[i]] * 0.133322) # Torr to kPa
elif var_units == 'mbar':
Expand Down

0 comments on commit 9d5b98e

Please sign in to comment.