lon = coords[1] bl,x,y = bil.bilinear(lat, lon, df) wind = bl['t_interp'] wind_hourly = wind.rename('wind_speed') wind_locations[key] = wind_hourly else: # ERA5 weather print('Using weather data from ERA5') parameters = { 'wind_u': 'u10', 'wind_v': 'v10' } download.weather_era5(input_path, year, 1, 'I', 'wind', ['10m_u_component_of_wind', '10m_v_component_of_wind'], [ 60, -8, 50, 2, ]) df_u = read.weather_era5(input_path, year, 1, 'I', 'wind','u10') df_v = read.weather_era5(input_path, year, 1, 'I', 'wind','v10') print(df_v) # for each location ... for key, generator in generators.items(): # blinearly interpolate wind from weather grid coords = generator['coords'] lat = coords[0] lon = coords[1] bl_u,x,y = bil.bilinear(lat, lon, df_u) bl_v,x,y = bil.bilinear(lat, lon, df_v) wind_u = bl_u['t_interp'] wind_v = bl_v['t_interp'] wind_squared = wind_u.pow(2) + wind_u.pow(2) wind_hourly = wind_squared.pow(1/2).rename('wind_speed') wind_locations[key] = wind_hourly
# read weather parameters = { 'air_temp': 't2m', 'soil_temp': 'stl4', 'wind_u': 'u10', 'wind_v': 'v10', 'pressure': 'sp', 'cloud': 'tcc', 'precipitation': 'ilspf', 'rain': 'lsrr', # 'precipitation_type': 'ptype', 'irradiance': 'ssrd', 'irradiance_cs': 'ssrdc' } weather = pd.concat([ read.weather_era5(output_path, year, hour, grid, 'weather', parameter) for parameter in parameters.values() ], keys=parameters.keys(), names=['parameter', 'latitude', 'longitude'], axis=1) print(weather) weather.to_pickle("/home/malcolm/uclan/output/correlation/weather/test.pickle") # map population to the weather grid population_filename = os.path.join(output_path, "population") if os.path.isfile(population_filename): s = pd.read_pickle(population_filename) print("mapped population read from file") else:
# read ERA5 input_path = "/home/malcolm/uclan/input/" interim_path = "/home/malcolm/uclan/interim/" year = '2018' download.weather_era5(input_path, year, 1, 'I', 'pv', [ 'surface_solar_radiation_downwards', 'surface_solar_radiation_downward_clear_sky' ], [ 60, -8, 50, 2, ]) df_ir = read.weather_era5(input_path, year, 1, 'I', 'pv', 'ssrd') df_ir, x, y = bil.bilinear(lat, lon, df_ir) era5_ir = df_ir['t_interp'] df_cs = read.weather_era5(input_path, year, 1, 'I', 'pv', 'ssrdc') df_cs, x, y = bil.bilinear(lat, lon, df_cs) era5_cs = df_cs['t_interp'] # convert from J/m2 to wh/m2 era5_ir = era5_ir * 0.000277778 era5_cs = era5_cs * 0.000277778 # print(era5_ir) # print(era5_cs) # read midas midas_file = "/home/malcolm/uclan/data/midas/midas-open_uk-radiation-obs_dv-201908_cornwall_01395_camborne_qcv-1_2018.csv" pv_hourly = read_midas_irradiance( midas_file, ['glbl_irad_amt', 'difu_irad_amt', 'direct_irad'])