Exemplo n.º 1
0
def forcing_from_thredds(sites, forc_vars):
    """

    :param sites: dict with site-name as key and list of [lat, lon] as value.
    .param forc_vars: list of forcing variables to be inserted as forcing
    :return:
    """
    thredds_url = "http://thredds.met.no/thredds/dodsC/arome25/arome_metcoop_test2_5km_latest.nc"
    thredds_file = netCDF4.Dataset(thredds_url, "r")
    latvar = thredds_file.variables["latitude"]
    lonvar = thredds_file.variables["longitude"]

    no_points = len(sites)
    point_index = [tunnel_fast(latvar, lonvar, coord[0], coord[1]) for coord in sites.values()]

    cnc = CrocusForcing(no_points=no_points, source="arome")  # init Crocus forcing file
    cnc.forc_time_step_v[:] = 3600.0

    for point in range(no_points):
        for var in forc_vars:
            cnc.insert_arome_var(var, thredds_file.variables)
        # cnc.tair_v[:, point] = thredds_file.variables[cnc.crocus_arome_lut[cnc.tair_v.name]][:, 0, point_index[point][0], point_index[point][1]]

    time_v = thredds_file.variables["time"]
    cnc.time_v[:] = time_v[:]
    cnc.time_v.units = time_v.units

    cnc.close()
    thredds_file.close()
Exemplo n.º 2
0
cnc.zs_v[:] = 950.0
cnc.lat_v[:] = 60.0
cnc.lon_v[:] = 10.0

# TODO: use date2num to get the time right
cnc.time_v[:] = time_v
cnc.time_v.units = t_units

# Set the created forcing parameters

#PTH
cnc.q_air_v[:, 0] = q_air[:]
cnc.tair_v[:, 0] = tair[:]
cnc.ps_surf_v[:, 0] = p_surf[:]
# Precip
cnc.rain_fall_v[:, 0] = rainf[:]
cnc.snow_fall_v[:, 0] = snowf[:]
# Radiation
cnc.dir_sw_down_v[:, 0] = dir_sw_down[:]
cnc.sca_sw_down_v[:, 0] = sca_sw_down[:]
cnc.lw_down_v[:, 0] = lw_down[:]
# Wind
cnc.wind_v[:, 0] = wind[:]
cnc.wind_dir_v[:, 0] = wind_dir[:]
# Others
cnc.co2_air_v[:, 0] = co2_air


cnc.create_options_nam()
cnc.close()