Skip to content

Commit

Permalink
Merge pull request NCAR#51 from jmills-ncar/master
Browse files Browse the repository at this point in the history
switched code and change open_nwmdataset
  • Loading branch information
T. Joe Mills authored May 2, 2018
2 parents ffdc00f + 8e493fd commit 28d100e
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 77 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='wrfhydropy',
version='0.0.2',
version='0.0.3dev0',
packages=find_packages(),
url='https://github.com/NCAR/wrf_hydro_py',
license='MIT',
Expand Down
14 changes: 12 additions & 2 deletions wrfhydropy/core/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import deepdiff
import xarray as xr
import pathlib
import numpy as np

def compare_nc_nccmp(candidate_nc: str,
reference_nc: str,
Expand Down Expand Up @@ -121,12 +122,16 @@ def diff_namelist(namelist1: str, namelist2: str, **kwargs) -> dict:


def open_nwmdataset(paths: list,
chunks: dict=None) -> xr.Dataset:
chunks: dict=None,
forecast: bool = True) -> xr.Dataset:
"""Open a multi-file wrf-hydro output dataset
Args:
paths: List ,iterable, or generator of file paths to wrf-hydro netcdf output files
chunks: chunks argument passed on to xarray DataFrame.chunk() method
forecast: If forecast the nreference time dimensions is retained, if not then
reference_time dimension is set to a dummy value (1970-01-01) to ease concatenation
and analysis
Returns:
An xarray dataset of dask arrays chunked by chunk_size along the feature_id
dimension concatenated along the time and
Expand All @@ -136,7 +141,12 @@ def open_nwmdataset(paths: list,
# Create dictionary of forecasts, i.e. reference times
ds_dict = dict()
for a_file in paths:
ds = xr.open_dataset(a_file)
ds = xr.open_dataset(a_file,chunks=chunks)
# Check if forecast and set reference_time to zero if not
if not forecast:
ds.coords['reference_time'].values = np.array(
[np.datetime64('1970-01-01T00:00:00', 'ns')])

ref_time = ds['reference_time'].values[0]
if ref_time in ds_dict:
# append the new number to the existing array at this slot
Expand Down
61 changes: 0 additions & 61 deletions wrfhydropy/tests/data/private/wrf_hydro_nwm/source/README.build

This file was deleted.

Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ sys_cpl = 1

!!!! ------------------- MODEL INPUT DATA FILES ------------------- !!!!

! Specify land surface model gridded input data file (e.g.: "geo_em.d03.nc")
GEO_STATIC_FLNM = "./DOMAIN/geo_em.d03.nc"
! Specify land surface model gridded input data file (e.g.: "geo_em.d01.nc")
GEO_STATIC_FLNM = "./DOMAIN/geo_em.d01.nc"

! Specify the high-resolution routing terrain input data file (e.g.: "Fulldom_hires.nc")
GEO_FINEGRID_FLNM = "./DOMAIN/Fulldom_hires.nc"

! Specify the spatial hydro parameters file (e.g.: "HYDRO_TBL_2D.nc")
! Specify the spatial hydro parameters file (e.g.: "hydro2dtbl.nc")
! If you specify a filename and the file does not exist, it will be created for you.
HYDROTBL_F = "./DOMAIN/HYDRO_TBL_2D.nc"
HYDROTBL_F = "./DOMAIN/hydro2dtbl.nc"

! Specify spatial metadata file for land surface grid. (e.g.: "geospatial_data_template_land_GIS.nc")
! Specify spatial metadata file for land surface grid. (e.g.: "GEOGRID_LDASOUT_Spatial_Metadata.nc")
LAND_SPATIAL_META_FLNM = "./DOMAIN/GEOGRID_LDASOUT_Spatial_Metadata.nc"

! Specify the name of the restart file if starting from restart...comment out with '!' if not...
Expand All @@ -25,7 +25,7 @@ RESTART_FILE = 'HYDRO_RST.2013-09-12_04:00_DOMAIN3'
!!!! --------------------- MODEL SETUP OPTIONS -------------------- !!!!

! Specify the domain or nest number identifier...(integer)
IGRID = 3
IGRID = 1

! Specify the restart file write frequency...(minutes)
! A value of -99999 will output restarts on the first day of the month only.
Expand Down Expand Up @@ -119,6 +119,7 @@ AGGFACTRT = 10

! Specify the channel routing model timestep...(seconds)
DTRT_CH = 10

! Specify the terrain routing model timestep...(seconds)
DTRT_TER = 10

Expand All @@ -134,6 +135,7 @@ rt_option = 1

! Switch to activate channel routing...(0=no, 1=yes)
CHANRTSWCRT = 1

! Specify channel routing option: 1=Muskingam-reach, 2=Musk.-Cunge-reach, 3=Diff.Wave-gridded
channel_option = 3

Expand All @@ -156,6 +158,7 @@ GWBUCKPARM_file = "./DOMAIN/GWBUCKPARM.nc"

! User defined mapping, such NHDPlus: 0=no (default), 1=yes
UDMP_OPT = 0

! If on, specify the user-defined mapping file (e.g.: "spatialweights.nc")
!udmap_file = "./DOMAIN/spatialweights.nc"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,12 @@

IZ0TLND = 0
SFCDIF_OPTION = 0
UPDATE_SNOW_FROM_FORCING = .TRUE.
UPDATE_SNOW_FROM_FORCING = .FALSE.

! Specification of forcing data: 1=HRLDAS-hr format, 2=HRLDAS-min format,
! 3=WRF, 4=Idealized, 5=Ideal w/ Spec.Precip.,
! 6=HRLDAS-hr format w/ Spec. Precip,
! 7=WRF w/Spec. Precip
FORC_TYP = 3

! Switch for snow data assimilation: 0=no, 1=yes
SNOW_ASSIM = 0

/
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
&NOAHLSM_OFFLINE

HRLDAS_SETUP_FILE = "./DOMAIN/wrfinput.nc"
HRLDAS_SETUP_FILE = "./DOMAIN/wrfinput_d01"
INDIR = "./FORCING"
SPATIAL_FILENAME = "./DOMAIN/soil_properties.nc"
OUTDIR = "./"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/bash

# This is called by both
# compile_offline_NoahMP.csh & compile_offline_Noah.csh.
# WRF-Hydro compile time options

# This is a WRF environment variable. Always set to 1=On for compiling WRF-Hydro.
export WRF_HYDRO=1
Expand Down

0 comments on commit 28d100e

Please sign in to comment.