def run_clark2009(catchment, output_dem, hydro_year_to_take, met_inp_folder,
                  catchment_shp_folder):
    """
    wrapper to call the clark 2009 snow model for given area
    :param catchment: string giving catchment area to run model on
    :param output_dem: string identifying the grid to run model on
    :param hydro_year_to_take: integer specifying the hydrological year to run model over. 2001 = 1/4/2000 to 31/3/2001
    :return: st_swe, st_melt, st_acc, out_dt, mask. daily grids of SWE at day's end, total melt and accumulation over the previous day, and datetimes of ouput
    """
    print('loading met data')
    data_id = '{}_{}'.format(catchment, output_dem)
    inp_met = nc.Dataset(
        met_inp_folder +
        '/met_inp_{}_hy{}.nc'.format(data_id, hydro_year_to_take), 'r')
    inp_dt = nc.num2date(inp_met.variables['time'][:],
                         inp_met.variables['time'].units)
    inp_doy = convert_date_hydro_DOY(inp_dt)
    inp_hourdec = [datt.hour for datt in inp_dt]
    inp_ta = inp_met.variables['temperature'][:]
    inp_precip = inp_met.variables['precipitation'][:]
    print('met data loaded')

    mask = create_mask_from_shpfile(
        inp_met.variables['lat'][:], inp_met.variables['lon'][:],
        catchment_shp_folder + '/{}.shp'.format(catchment))
    # TODO: think about masking input data to speed up

    print('starting snow model')
    # start with no snow.
    # call main function once hourly/sub-hourly temp and precip data available.
    st_swe, st_melt, st_acc = snow_main_simple(inp_ta,
                                               inp_precip,
                                               inp_doy,
                                               inp_hourdec,
                                               dtstep=3600)
    out_dt = np.asarray(
        make_regular_timeseries(inp_dt[0], inp_dt[-1] + dt.timedelta(days=1),
                                86400))

    print('snow model finished')

    # mask out values outside of catchment
    st_swe[:, mask == False] = np.nan
    st_melt[:, mask == False] = np.nan
    st_acc[:, mask == False] = np.nan

    return st_swe, st_melt, st_acc, out_dt, mask
Example #2
0
                                                       lat_array, lon_array,
                                                       mask.copy(), y_centres,
                                                       x_centres)
    else:
        mask = None
        lats = lat_array
        lons = lon_array
        elev = nztm_dem
        northings = y_centres
        eastings = x_centres

    for year_to_take in years_to_take:
        # load data
        # create timestamp to get - this is in NZST
        dts_to_take = np.asarray(
            make_regular_timeseries(dt.datetime(year_to_take, 1, 1),
                                    dt.datetime(year_to_take, 12, 31), 86400))
        # pull only data needed.
        # this loads data for 00h NZST that corresponds to the day to come in i.e. min@ 8am, max @ 2pm , total sw and total rain for 1/1/2000 at 2000-01-01 00:00:00
        # precip_daily = load_new_vscn('rain', dts_to_take, nc_file_rain)
        # max_temp_daily = load_new_vscn('tmax', dts_to_take, nc_file_tmax)
        # min_temp_daily = load_new_vscn('tmin', dts_to_take, nc_file_tmin)
        sw_rad_daily = load_new_vscn('srad', dts_to_take, nc_file_srad)
        # load grid (assume same for all input data)
        ds = nc.Dataset(nc_file_srad)
        vcsn_elev = np.flipud(ds.variables['elevation'][:])
        vcsn_lats = ds.variables['latitude'][::-1]
        vcsn_lons = ds.variables['longitude'][:]
        hy_index = np.ones(dts_to_take.shape, dtype='int')

        # check dimensions and projection of the new data
        # nztm_elev_check = interpolate_met(np.asarray([vcsn_elev]), Precip, vcsn_lons, vcsn_lats, vcsn_elev, lons,
Example #3
0
def run_snow_otf_nzcsm_main(hydro_years_to_take, run_id, met_inp, which_model, catchment, output_dem, mask_dem, mask_folder, dem_folder, output_folder, data_folder,
                      orog_infile, precip_infile, air_temp_infile, solar_rad_infile, config):
    if not os.path.exists(output_folder):
        os.makedirs(output_folder)

    # open input met data files
    nc_file_orog = nc.Dataset(data_folder + '/' + orog_infile, 'r')

    nc_file_rain = nc.Dataset(data_folder + '/' + precip_infile, 'r')
    nc_file_temp = nc.Dataset(data_folder + '/' + air_temp_infile, 'r')

    nc_rain = nc_file_rain.variables['sum_total_precip']
    nc_temp = nc_file_temp.variables['sfc_temp']

    if which_model == 'dsc_snow':
        nc_file_srad = nc.Dataset(data_folder + '/' + solar_rad_infile, 'r')
        nc_srad = nc_file_srad.variables['sfc_dw_sw_flux']
        vcsn_dt4 = nc.num2date(nc_file_srad.variables['time1'][:], nc_file_srad.variables['time1'].units,only_use_cftime_datetimes=False,only_use_python_datetimes=True)

    # load met grid (assume same for all input data)
    vcsn_elev = nc_file_orog.variables['orog_model'][:]
    vcsn_elev_interp = vcsn_elev.copy()
    vcsn_lats = nc_file_orog.variables['rlat'][:]
    vcsn_lons = nc_file_orog.variables['rlon'][:]
    rot_pole = nc_file_orog.variables['rotated_pole']
    rot_pole_crs = ccrs.RotatedPole(rot_pole.grid_north_pole_longitude, rot_pole.grid_north_pole_latitude, rot_pole.north_pole_grid_longitude)

    vcsn_dt = nc.num2date(nc_file_rain.variables['time2'][:], nc_file_rain.variables['time2'].units,only_use_cftime_datetimes=False,only_use_python_datetimes=True)
    vcsn_dt2 = nc.num2date(nc_file_temp.variables['time0'][:], nc_file_temp.variables['time0'].units,only_use_cftime_datetimes=False,only_use_python_datetimes=True)


    # calculate model grid etc:
    # output DEM
    dem_file = dem_folder + '/' + output_dem + '.tif'
    if output_dem == 'si_dem_250m':
        nztm_dem, x_centres, y_centres, lat_array, lon_array = setup_nztm_dem(dem_file, extent_w=1.08e6, extent_e=1.72e6, extent_n=5.52e6, extent_s=4.82e6,
                                                                              resolution=250)
    elif output_dem == 'nz_dem_250m':
        nztm_dem, x_centres, y_centres, lat_array, lon_array = setup_nztm_dem(dem_file, extent_w=1.05e6, extent_e=2.10e6, extent_n=6.275e6, extent_s=4.70e6,
                                                                              resolution=250, origin='bottomleft')
    else:
        print('incorrect dem chosen')

    if mask_dem == True:
        # Get the masks for the individual regions of interest
        mask = np.load(mask_folder + '/{}_{}.npy'.format(catchment, output_dem))
        # Trim down the number of latitudes requested so it all stays in memory
        wgs84_lats, wgs84_lons, elev, northings, eastings = trim_lat_lon_bounds(mask, lat_array, lon_array, nztm_dem, y_centres, x_centres)
        _, _, trimmed_mask, _, _ = trim_lat_lon_bounds(mask, lat_array, lon_array, mask.copy(), y_centres, x_centres)
    else:
        wgs84_lats = lat_array
        wgs84_lons = lon_array
        elev = nztm_dem
        northings = y_centres
        eastings = x_centres
        # set mask to all land points
        mask = elev > 0
        trimmed_mask = mask
    # calculate lat/lon on rotated grid of input
    yy, xx = np.meshgrid(northings, eastings, indexing='ij')
    rotated_coords = rot_pole_crs.transform_points(ccrs.epsg(2193), xx, yy)
    rlats = rotated_coords[:, :, 1]
    rlons = rotated_coords[:, :, 0]
    rlons[rlons < 0] = rlons[rlons < 0] + 360

    # set up time to run, paths to input files etc
    for year_to_take in hydro_years_to_take:
        print(year_to_take)
        # specify the days to run (output is at the end of each day)
        # out_dt = np.asarray(make_regular_timeseries(dt.datetime(year_to_take, 7, 1), dt.datetime(year_to_take, 7, 2), 86400))
        out_dt = np.asarray(make_regular_timeseries(dt.datetime(year_to_take - 1, 4, 1), dt.datetime(year_to_take, 4, 1), 86400))

        # set up output netCDF:
        out_nc_file = setup_nztm_grid_netcdf(
            output_folder + '/snow_out_{}_{}_{}_{}_{}_{}.nc'.format(met_inp, which_model, catchment, output_dem, run_id, year_to_take),
            None, ['swe', 'acc', 'melt', 'rain', 'ros', 'ros_melt'],
            out_dt, northings, eastings, wgs84_lats, wgs84_lons, elev)

        # set up initial states of prognostic variables
        init_swe = np.zeros(elev.shape)  # default to no snow
        init_d_snow = np.ones(elev.shape) * 30  # default to a month since snowfall
        swe = init_swe
        d_snow = init_d_snow
        # set up daily buckets for melt and accumulation
        bucket_melt = swe * 0
        bucket_acc = swe * 0
        swe_day_before = swe * 0
        bucket_rain = swe * 0
        bucket_ros = swe * 0
        bucket_ros_melt = swe * 0

        # store initial swe value
        out_nc_file.variables['swe'][0, :, :] = init_swe
        out_nc_file.variables['acc'][0, :, :] = 0
        out_nc_file.variables['melt'][0, :, :] = 0
        out_nc_file.variables['rain'][0, :, :] = 0
        out_nc_file.variables['ros'][0, :, :] = 0
        out_nc_file.variables['ros_melt'][0, :, :] = 0

        # for each day:
        for ii, dt_t in enumerate(out_dt[:-1]):
            print('processing', dt_t)
            # load one day of precip and shortwave rad data
            precip_hourly = nc_rain[int(np.where(vcsn_dt == dt_t)[0]):int(int(np.where(vcsn_dt == dt_t)[0]) + 24)]
            temp_hourly = nc_temp[int(np.where(vcsn_dt2 == dt_t)[0]):int(np.where(vcsn_dt2 == dt_t)[0]) + 24]

            # interpolate data to fine grid
            hi_res_precip = interpolate_met(precip_hourly.filled(np.nan), 'rain', vcsn_lons, vcsn_lats, vcsn_elev_interp, rlons, rlats, elev)
            hi_res_temp = interpolate_met(temp_hourly.filled(np.nan), 'tmax', vcsn_lons, vcsn_lats, vcsn_elev_interp, rlons, rlats, elev)

            # mask out areas we don't want/need
            if mask is not None:
                hi_res_precip[:, trimmed_mask == 0] = np.nan
                hi_res_temp[:, trimmed_mask == 0] = np.nan

            hourly_dt = np.asarray(make_regular_timeseries(dt_t, dt_t + dt.timedelta(hours=23), 3600))
            hourly_doy = convert_datetime_julian_day(hourly_dt)
            hourly_temp = hi_res_temp
            hourly_precip = hi_res_precip

            if which_model == 'dsc_snow':
                sw_rad_hourly = nc_srad[int(np.where(vcsn_dt4 == dt_t)[0]):int(np.where(vcsn_dt4 == dt_t)[0]) + 24]
                hi_res_sw_rad = interpolate_met(sw_rad_hourly.filled(np.nan), 'srad', vcsn_lons, vcsn_lats, vcsn_elev_interp, rlons, rlats, elev)
                if mask is not None:
                    hi_res_sw_rad[:, trimmed_mask == 0] = np.nan
                hourly_swin = hi_res_sw_rad

            # calculate snow and output to netcdf
            for i in range(len(hourly_dt)):
                # d_snow += dtstep / 86400.0
                if which_model == 'dsc_snow':
                    swe, d_snow, melt, acc = calc_dswe(swe, d_snow, hourly_temp[i], hourly_precip[i], hourly_doy[i], 3600, which_melt=which_model,
                                                       sw=hourly_swin[i],
                                                       **config)  #
                else:
                    swe, d_snow, melt, acc = calc_dswe(swe, d_snow, hourly_temp[i], hourly_precip[i], hourly_doy[i], 3600, which_melt=which_model,
                                                       **config)
                # print swe[0]
                bucket_melt = bucket_melt + melt
                bucket_acc = bucket_acc + acc
                rain = hourly_precip[i] - acc
                bucket_rain = bucket_rain + rain
                bucket_ros = bucket_ros + rain * (swe > 0).astype(np.int)  # creates binary snow cover then multiples by rain (0 or 1)

                # first calculate the energy availble for melting due to rainfall (Wm^-2) over snowcovered cells only
                qprc = (swe > 0).astype(np.int) * 4220. * rain / 3600. * (hourly_temp[i] - 273.16)
                # then calculate potential melt per timestep . don't limit to available swe as could have contributed to intial snow melt (accounted for by degree-day model)
                ros_melt = qprc / 334000. * 3600.
                ros_melt[(ros_melt < 0)] = 0  # only take positive portion (could be some rain at air temperature < 0)
                bucket_ros_melt = bucket_ros_melt + ros_melt
            # output at the end of each day,
            for var, data in zip(['swe', 'acc', 'melt', 'rain', 'ros', 'ros_melt'], [swe, bucket_acc, bucket_melt, bucket_rain, bucket_ros, bucket_ros_melt]):
                # data[(np.isnan(data))] = -9999.
                out_nc_file.variables[var][ii + 1, :, :] = data

            # decide if albedo is reset
            d_snow += 1
            swe_alb = swe - swe_day_before
            d_snow[(swe_alb > config['alb_swe_thres'])] = 0
            swe_day_before = swe * 1.0
            # reset buckets
            bucket_melt = bucket_melt * 0
            bucket_acc = bucket_acc * 0
            bucket_rain = bucket_rain * 0
            bucket_ros = bucket_ros * 0
            bucket_ros_melt = bucket_ros_melt * 0
        out_nc_file.close()

        json.dump(config, open(output_folder + '/config_{}_{}_{}_{}_{}_{}.json'.format(met_inp, which_model, catchment, output_dem, run_id, year_to_take), 'w'))
        pickle.dump(config,
                    open(output_folder + '/config_{}_{}_{}_{}_{}_{}.pkl'.format(met_inp, which_model, catchment, output_dem, run_id, year_to_take), 'wb'),
                    protocol=3)
config['tc'] = 10
config['a_ice'] = 0.42
config['a_freshsnow'] = 0.95
config['a_firn'] = 0.62
config['alb_swe_thres'] = 20
config['ros'] = True  # include rain on snow
config[
    'ta_m_tt'] = False  # use melt threshold for calculating magnitude of temperature dependent melt (default is False = use 273.15).

# load brewster glacier data
inp_dat = np.genfromtxt(
    'C:/Users/conwayjp/OneDrive - NIWA/projects/DSC Hydro/BrewsterGlacier_Oct10_Sep12_mod3.dat'
)
start_t = 9600 - 1  # 9456 = start of doy 130 10th May 2011 9600 = end of 13th May,18432 = start of 11th Nov 2013,19296 = 1st december 2011
end_t = 21360  # 20783 = end of doy 365, 21264 = end of 10th January 2012, 21360 = end of 12th Jan
inp_dt = make_regular_timeseries(dt.datetime(2010, 10, 25, 00, 30),
                                 dt.datetime(2012, 9, 2, 00, 00), 1800)

inp_doy = inp_dat[start_t:end_t, 2]
inp_hourdec = inp_dat[start_t:end_t, 3]
# make grids of input data
grid_size = 1
grid_id = np.arange(grid_size)
inp_ta = inp_dat[start_t:end_t, 7][:, np.newaxis] * np.ones(
    grid_size) + 273.16  # 2 metre air temp in C
inp_precip = inp_dat[start_t:end_t, 21][:, np.newaxis] * np.ones(
    grid_size)  # precip in mm
inp_sw = inp_dat[start_t:end_t, 15][:, np.newaxis] * np.ones(grid_size)
inp_sfc = inp_dat[start_t - 1:end_t, 19]  # surface height change
inp_sfc -= inp_sfc[0]  # reset to 0 at beginning of period

# validation data
Example #5
0
    if which_model == 'clark2009':
        config['tmelt'] = 273.16
    if which_model == 'dsc_snow':
        config['tmelt'] = 274.16
    for hydro_year_to_take in hydro_years_to_take:
        # run model and return timeseries of daily swe, acc and melt.
        met_infile = met_data_folder + '/met_inp_{}_{}_hy{}.nc'.format(
            catchment, output_dem, hydro_year_to_take)
        st_swe, st_melt, st_acc = snow_main(met_infile,
                                            which_melt=which_model,
                                            **config)
        # create the extra variables required by catchment_evaluation
        inp_met = nc.Dataset(met_infile, 'r')
        inp_dt = nc.num2date(inp_met.variables['time'][:],
                             inp_met.variables['time'].units)
        out_dt = np.asarray(
            make_regular_timeseries(inp_dt[0], inp_dt[-1], 86400))
        mask = create_mask_from_shpfile(
            inp_met.variables['lat'][:], inp_met.variables['lon'][:],
            catchment_shp_folder + '/{}.shp'.format(catchment))
        pickle.dump(
            [
                st_swe.astype(dtype=np.float32),
                st_melt.astype(dtype=np.float32),
                st_acc.astype(dtype=np.float32), out_dt, mask, config
            ],
            open(
                output_folder + '/{}_{}_hy{}_{}.pkl'.format(
                    catchment, output_dem, hydro_year_to_take, which_model),
                'wb'), -1)
Example #6
0
    calc_grid = True  # calculate for whole grid?

    if calc_grid == False:
        lat_to_get = -44.075
        lon_to_get = 169.425

        nc_file_rain = 'T:/newVCSN/rain_vclim_clidb_1972010100_2017102000_south-island_p05_daily.nc'
        nc_file_tmax = 'T:/newVCSN/tmax_vclim_clidb_1972010100_2017102000_south-island_p05_daily.nc'
        nc_file_tmin = 'T:/newVCSN/tmin_vclim_clidb_1972010100_2017102000_south-island_p05_daily.nc'
        nc_file_srad = 'T:/newVCSN/srad_vclim_clidb_1972010100_2017102000_south-island_p05_daily.nc'

        point_to_get = find_vcsn_point(lat_to_get, lon_to_get, nc_file_rain)

        dts_to_take = np.asarray(
            make_regular_timeseries(dt.datetime(2001 - 1, 4, 1),
                                    dt.datetime(2016, 3, 31), 86400))
        # pull only data needed.
        # this loads data for 00h NZST that corresponds to the day to come in i.e. min@ 8am, max @ 2pm , total sw and total rain for 1/1/2000 at 2000-01-01 00:00:00
        precip_daily = load_new_vscn('rain',
                                     dts_to_take,
                                     nc_file_rain,
                                     point=point_to_get)
        max_temp_daily = load_new_vscn('tmax',
                                       dts_to_take,
                                       nc_file_tmax,
                                       point=point_to_get)
        min_temp_daily = load_new_vscn('tmin',
                                       dts_to_take,
                                       nc_file_tmin,
                                       point=point_to_get)
        sw_rad_daily = load_new_vscn('srad',
Example #7
0
                                                       x_centres)
    else:
        mask = None
        lats = lat_array
        lons = lon_array
        elev = nztm_dem
        northings = y_centres
        eastings = x_centres

    ann_mean_precip = []

    for year_to_take in years_to_take:
        # load data
        # create timestamp to get - this is in NZST
        dts_to_take = np.asarray(
            make_regular_timeseries(dt.datetime(year_to_take, 1, 1),
                                    dt.datetime(year_to_take, 12, 31), 86400))
        # pull only data needed.
        # this loads data for 00h NZST that corresponds to the day to come in i.e. min@ 8am, max @ 2pm , total sw and total rain for 1/1/2000 at 2000-01-01 00:00:00
        # precip_daily = load_new_vscn('rain', dts_to_take, nc_file_rain)
        # max_temp_daily = load_new_vscn('tmax', dts_to_take, nc_file_tmax)
        # # min_temp_daily = load_new_vscn('tmin', dts_to_take, nc_file_tmin)
        # sw_rad_daily = load_new_vscn('srad', dts_to_take, nc_file_srad)
        # # load grid (assume same for all input data)
        # ds = nc.Dataset(nc_file_srad)
        # vcsn_elev = np.flipud(ds.variables['elevation'][:])
        # vcsn_lats = ds.variables['latitude'][::-1]
        # vcsn_lons = ds.variables['longitude'][:]
        # hy_index = np.ones(dts_to_take.shape, dtype='int')

        # check dimensions and projection of the new data
        # nztm_elev_check = interpolate_met(np.asarray([vcsn_elev]), Precip, vcsn_lons, vcsn_lats, vcsn_elev, lons,
Example #8
0
    _, _, trimmed_mask, _, _ = trim_lat_lon_bounds(mask, lat_array, lon_array,
                                                   mask.copy(), y_centres,
                                                   x_centres)

# calculate rotated grid lat/lon of output grid
yy, xx = np.meshgrid(northings, eastings, indexing='ij')
rotated_coords = rot_pole_crs.transform_points(ccrs.epsg(2193), xx, yy)
rlats = rotated_coords[:, :, 1]
rlons = rotated_coords[:, :, 0]
rlons[rlons < 0] = rlons[rlons < 0] + 360

# set up output times
first_time = parser.parse(config['output_file']['first_timestamp'])
last_time = parser.parse(config['output_file']['last_timestamp'])
out_dt = np.asarray(
    make_regular_timeseries(first_time, last_time,
                            config['output_file']['timestep']))
print('time output from {} to {}'.format(first_time.strftime('%Y-%m-%d %H:%M'),
                                         last_time.strftime('%Y-%m-%d %H:%M')))

# set up output netCDF without variables
if not os.path.exists(config['output_file']['output_folder']):
    os.makedirs(config['output_file']['output_folder'])
output_file = config['output_file']['file_name_template'].format(
    first_time.strftime('%Y%m%d%H%M'), last_time.strftime('%Y%m%d%H%M'))
out_nc_file = setup_nztm_grid_netcdf(
    config['output_file']['output_folder'] + output_file, None, [], out_dt,
    northings, eastings, wgs84_lats, wgs84_lons, elev)
# run through each variable
for var in config['variables'].keys():
    print('processing {}'.format(var))
    t = out_nc_file.createVariable(config['variables'][var]['output_name'],
        lats, lons, elev, northings, eastings = trim_lat_lon_bounds(mask, lat_array, lon_array, nztm_dem, y_centres, x_centres)
        _, _, trimmed_mask, _, _ = trim_lat_lon_bounds(mask, lat_array, lon_array, mask.copy(), y_centres, x_centres)
    else:
        mask = None
        lats = lat_array
        lons = lon_array
        elev = nztm_dem
        northings = y_centres
        eastings = x_centres

    ann_mean_precip = []

    for year_to_take in years_to_take:
        # load data
        # create timestamp to get - this is in NZST
        dts_to_take = np.asarray(make_regular_timeseries(dt.datetime(year_to_take, 1, 1), dt.datetime(year_to_take, 12, 31), 86400))
        # pull only data needed.
        # this loads data for 00h NZST that corresponds to the day to come in i.e. min@ 8am, max @ 2pm , total sw and total rain for 1/1/2000 at 2000-01-01 00:00:00
        # precip_daily = load_new_vscn('rain', dts_to_take, nc_file_rain)
        # max_temp_daily = load_new_vscn('tmax', dts_to_take, nc_file_tmax)
        # # min_temp_daily = load_new_vscn('tmin', dts_to_take, nc_file_tmin)
        # sw_rad_daily = load_new_vscn('srad', dts_to_take, nc_file_srad)
        # # load grid (assume same for all input data)
        # ds = nc.Dataset(nc_file_srad)
        # vcsn_elev = np.flipud(ds.variables['elevation'][:])
        # vcsn_lats = ds.variables['latitude'][::-1]
        # vcsn_lons = ds.variables['longitude'][:]
        # hy_index = np.ones(dts_to_take.shape, dtype='int')

        # check dimensions and projection of the new data
        # nztm_elev_check = interpolate_met(np.asarray([vcsn_elev]), Precip, vcsn_lons, vcsn_lats, vcsn_elev, lons,
Example #10
0
                                                   mask.copy(), y_centres,
                                                   x_centres)
else:
    mask = None
    lats = lat_array
    lons = lon_array
    elev = nztm_dem
    northings = y_centres
    eastings = x_centres

# set up time to run, paths to input files etc
for year_to_take in years_to_take:
    # specify the days to run (output is at the end of each day)
    # out_dt = np.asarray(make_regular_timeseries(dt.datetime(year_to_take, 7, 1), dt.datetime(year_to_take, 7, 2), 86400))
    out_dt = np.asarray(
        make_regular_timeseries(dt.datetime(year_to_take, 1, 1),
                                dt.datetime(year_to_take + 1, 1, 1), 86400))

    # set up output netCDF:
    out_nc_file = setup_nztm_grid_netcdf(
        output_folder +
        '/snow_out_{}_{}_{}.nc'.format(catchment, output_dem, year_to_take),
        None, ['swe', 'acc', 'melt'], out_dt, northings, eastings, lats, lons,
        elev)

    # set up initial states of prognostic variables
    init_swe = np.zeros(elev.shape)  # default to no snow
    init_d_snow = np.ones(elev.shape) * 30  # default to a month since snowfall
    swe = init_swe
    d_snow = init_d_snow
    # set up daily buckets for melt and accumulation
    bucket_melt = swe * 0