diff --git a/DataRequest.py b/DataRequest.py new file mode 100644 index 0000000..9ff100f --- /dev/null +++ b/DataRequest.py @@ -0,0 +1,154 @@ +import cdsapi +from input.user_input import * + +# start_lat = 78.22 Svalbard +# start_lon = 15.65 + +# start_lat = 67.887382 Kiruna +# start_lon = 21.081452 + +startdays = ['23', '24', '25', '26', '27', '28', '29', '30', '31'] +days = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31'] +endascent = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22'] +endfloat = ['1'] + +def ERAsingle(year, month, days, north_lim, south_lim, east_lim, west_lim, name): + single = cdsapi.Client().retrieve( + 'reanalysis-era5-single-levels', + { + 'product_type': 'reanalysis', + 'format': 'netcdf', + 'variable': [ + 'cloud_base_height', 'high_cloud_cover', 'low_cloud_cover', 'medium_cloud_cover', + 'skin_temperature', 'surface_net_solar_radiation', 'surface_net_thermal_radiation', + 'surface_pressure', 'surface_solar_radiation_downwards', 'surface_thermal_radiation_downward_clear_sky', + 'surface_thermal_radiation_downwards', 'toa_incident_solar_radiation', + 'top_net_solar_radiation', 'top_net_thermal_radiation', 'total_cloud_cover', + 'total_sky_direct_solar_radiation_at_surface', + ], + 'time': [ + '00:00', '01:00', '02:00', + '03:00', '04:00', '05:00', + '06:00', '07:00', '08:00', + '09:00', '10:00', '11:00', + '12:00', '13:00', '14:00', + '15:00', '16:00', '17:00', + '18:00', '19:00', '20:00', + '21:00', '22:00', '23:00', + ], + 'year': str(year), + 'month': str(month), + 'day': days, + 'area': [ + north_lim, west_lim, south_lim, # north_lim, west_lim, south_lim, # North, West, South 72, -111, 67, + east_lim, # east_lim, # East 22, + ], + }) + single.download(name) + + +def ERAlevelAscend(year, month, days, start_lat, start_lon, name): + north_lim = start_lat + 10.0 + south_lim = start_lat - 10.0 + east_lim = start_lon - 10.0 + west_lim = start_lon + 10.0 + + ascend = cdsapi.Client().retrieve( + 'reanalysis-era5-pressure-levels', + { + 'product_type': 'reanalysis', + 'format': 'netcdf', + 'variable': [ + 'geopotential', 'temperature', 'u_component_of_wind', + 'v_component_of_wind', 'vertical_velocity', + ], + 'pressure_level': [ + '1', '2', '3', + '5', '7', '10', + '20', '30', '50', + '70', '100', '125', + '150', '175', '200', + '225', '250', '300', + '350', '400', '450', + '500', '550', '600', + '650', '700', '750', + '775', '800', '825', + '850', '875', '900', + '925', '950', '975', + '1000', + ], + 'year': str(year), + 'month': str(month), + 'day': days, + 'time': [ + '00:00', '01:00', '02:00', + '03:00', '04:00', '05:00', + '06:00', '07:00', '08:00', + '09:00', '10:00', '11:00', + '12:00', '13:00', '14:00', + '15:00', '16:00', '17:00', + '18:00', '19:00', '20:00', + '21:00', '22:00', '23:00', + ], + 'area': [ + north_lim, west_lim, south_lim, + east_lim, + ], + }) + ascend.download(name) + + +def ERAlevelFloat(year, month, days, north_lim, south_lim, east_lim, west_lim, name): + floating = cdsapi.Client().retrieve( + 'reanalysis-era5-pressure-levels', + { + 'product_type': 'reanalysis', + 'format': 'netcdf', + 'variable': [ + 'geopotential', 'temperature', 'u_component_of_wind', + 'v_component_of_wind', 'vertical_velocity', + ], + 'pressure_level': [ + '1', '2', '3', + '5', '7', '10', + '20', + ], + 'year': str(year), + 'month': str(month), + 'day': days, + 'time': [ + '00:00', '01:00', '02:00', + '03:00', '04:00', '05:00', + '06:00', '07:00', '08:00', + '09:00', '10:00', '11:00', + '12:00', '13:00', '14:00', + '15:00', '16:00', '17:00', + '18:00', '19:00', '20:00', + '21:00', '22:00', '23:00', + ], + 'area': [ + north_lim, west_lim, south_lim, + east_lim, + ], + }) + floating.download(name) + + +##ERAsingle(2018, 5, startdays, 90, 45, 180, -180, "single_2018_1.nc") +##ERAsingle(2018, 6, days, 90, 45, 180, -180, "single_2018_2.nc") +##ERAsingle(2018, 7, days, 90, 45, 180, -180, "single_2018_3.nc") +##ERAsingle(2018, 8, endfloat, 90, 45, 180, -180, "single_2018_4.nc") + +##ERAlevelAscend(2018, 5, startdays, start_lat, start_lon, "ascend_2018_kiruna_1.nc") # start_lat = 67.887382 Kiruna +ERAlevelAscend(2018, 6, endascent, start_lat, start_lon, "ascend_2018_kiruna_2.nc") # start_lon = 21.081452 + +ERAlevelFloat(2018, 5, startdays, 90, 45, -180, 180, "float_2018_1.nc") +ERAlevelFloat(2018, 6, days, 90, 45, -180, 180, "float_2018_2.nc") +ERAlevelFloat(2018, 7, days, 90, 45, -180, 180, "float_2018_3.nc") +ERAlevelFloat(2018, 8, endfloat, 90, 45, -180, 180, "float_2018_4.nc") + +#ERAlevelAscend(2016, 7, ['12', '13', '14'], start_lat, start_lon, "ascend_2016_kiruna_new.nc") +#ERAsingle(2016, 7, ['12', '13', '14', '15', '16', '17', '18', '19'], 90, 45, 180, -180, "single_2016_new.nc") +#ERAlevelFloat(2016, 7, ['12', '13', '14', '15', '16', '17', '18', '19'], 90, 45, -180, 180, "float_2016_new.nc") + +