Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Cannot retrieve ERA5 data #89

Closed
adamsigi opened this issue Oct 8, 2024 · 1 comment
Closed

Cannot retrieve ERA5 data #89

adamsigi opened this issue Oct 8, 2024 · 1 comment

Comments

@adamsigi
Copy link

adamsigi commented Oct 8, 2024

Hello,
I am trying to run the example notebook, but I am getting an error when downloading ERA5 data.

Specifically, when executing Floodpy_app.download_ERA5_Precipitation_data() I am getting a 404 error:

File ~/miniconda3/envs/floodpy_gpu/lib/python3.8/site-packages/cads_api_client/processing.py:84, in cads_raise_for_status(response)
     77     else:
     78         message = "\n".join(
     79             [
     80                 f"{response.status_code} Client Error: {response.reason} for url: {response.url}",
     81                 error_json_to_message(error_json),
     82             ]
     83         )
---> 84         raise requests.HTTPError(message, response=response)
     85 response.raise_for_status()

HTTPError: 404 Client Error: Not Found for url: https://cds.climate.copernicus.eu/api/v2/retrieve/v1/processes/reanalysis-era5-single-levels

After some research I changed the url in .cdsapirc from https://cds.climate.copernicus.eu/api/v2 to https://cds.climate.copernicus.eu/api as described here: https://cds.climate.copernicus.eu/how-to-api

Now the data is being downloaded, but there is an error during parsing ☹️

1 ## Downloading Precipitation from ERA5 model
----> 2 Floodpy_app.download_ERA5_Precipitation_data()

File ~/floodpy/FLOODPY/floodpy/FLOODPYapp.py:128, in FloodwaterEstimation.download_ERA5_Precipitation_data(self)
    126 def download_ERA5_Precipitation_data(self):
--> 128     self.precipitation_df = Get_ERA5_data(ERA5_variables = ['total_precipitation',],
    129                                         start_datetime = self.pre_flood_datetime_start,
    130                                         end_datetime = self.flood_datetime_end ,
    131                                         bbox = self.bbox,
    132                                         ERA5_dir = self.ERA5_dir )
    134     print("Precipitation data can be found at {}".format(self.ERA5_dir))

File ~/floodpy/FLOODPY/floodpy/Download/Download_ERA5_precipitation.py:178, in Get_ERA5_data(ERA5_variables, start_datetime, end_datetime, bbox, ERA5_dir)
    176 elif ERA5_variable!='expver':
    177     temp_name=ERA5_variable+'__'+ERA5_data[ERA5_variable].units
--> 178     temp_dataset=np.mean(np.mean(ERA5_data[ERA5_variable][:],axis=1), axis=1)
    179     if len(temp_dataset.shape)>1:
    180         temp_dataset=np.mean(temp_dataset,axis=1)

File <__array_function__ internals>:200, in mean(*args, **kwargs)

...

File ~/miniconda3/envs/floodpy_gpu/lib/python3.8/site-packages/numpy/core/_methods.py:77, in _count_reduce_items(arr, axis, keepdims, where)
     75     items = 1
     76     for ax in axis:
---> 77         items *= arr.shape[mu.normalize_axis_index(ax, arr.ndim)]
     78     items = nt.intp(items)
     79 else:
     80     # TODO: Optimize case when `where` is broadcast along a non-reduction
     81     # axis and full sum is more excessive than needed.
     82 
     83     # guarded to protect circular imports

AxisError: axis 1 is out of bounds for array of dimension 0

It seems the ERA5_variables received in the Get_ERA5_data function are slightly different than those expected.

Since I have successfully run floodpy before, I think the problem might come from changes in the CDS api or maybe some configuration mistake on my side?

Thanks in advance :)

kleok added a commit that referenced this issue Oct 12, 2024
@kleok
Copy link
Owner

kleok commented Oct 12, 2024

@adamsigi thank you for using Floodpy! The issue you encountered is related to recent updates from the CDS API. I’ve made the necessary changes, including updates to the README file and the ERA5 downloading functionality. Could you please check if everything is running smoothly now?

@kleok kleok closed this as completed Oct 22, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants