Closed paolocristofanelli closed 1 year ago
Yes, that's a notebook for wp4. Are you going to need it skill_metrics for your notebook (I think it's used to plot taylor diagrams)? If yes, I'll install it on wp5 as well.
(If you don't need taylor diagrams, you should be able to comment out import skill_metrics
, and run the whole notebook with exception of the last cell)
Also, if you want to take advantage of the cache, you should probably run it as a wp4 user.
AttributeError Traceback (most recent call last) Cell In[9], line 14 11 request_model = request_sim 12 request_model[1]["model"] = model 13 datasets.append( ---> 14 download.download_and_transform( 15 *request_model, 16 chunks=chunks, 17 transform_func=spatial_weighted_trends, 18 transform_func_kwargs={"model": model, **transform_func_kwargs}, 19 transform_chunks=False, 20 ) 21 ) 23 # Combine and add ensemble 24 ds_spatial_weighted = xr.concat(datasets, "model")
File /data/common/mambaforge/envs/wp5/lib/python3.10/site-packages/c3s_eqc_automatic_quality_control/download.py:528, in download_and_transform(collection_id, requests, chunks, split_all, transform_func, transform_func_kwargs, transform_chunks, n_jobs, open_mfdataset_kwargs) 525 ds = xr.open_mfdataset(sources, open_mfdataset_kwargs) 526 else: 527 # Cache final dataset transformed --> 528 ds = func(request_list=request_list) 530 ds.attrs.pop("coordinates", None) # Previously added to guarantee roundtrip 531 return ds
File /data/common/mambaforge/envs/wp5/lib/python3.10/site-packages/cacholote/cache.py:86, in cacheable.
File /data/common/mambaforge/envs/wp5/lib/python3.10/site-packages/c3s_eqc_automatic_quality_control/download.py:433, in _download_and_transform_requests(collection_id, request_list, transform_func, transform_func_kwargs, open_mfdataset_kwargs)
430 ds = xr.open_mfdataset(sources, open_mfdataset_kwargs)
432 if transform_func is not None:
--> 433 ds = transform_func(ds, **transform_func_kwargs)
434 if not isinstance(ds, xr.Dataset):
435 raise TypeError(
436 f"transform_func
must return a xr.Dataset, while it returned {type(ds)}"
437 )
Cell In[8], line 37, in spatial_weighted_trends(ds, model, clima_year_start, clima_year_stop) 35 da = ds["precipitation"] 36 else: ---> 37 da = diagnostics.spatial_weighted_mean(get_annual_precipitation(ds, model)) 38 anoma = compute_anomaly(da, clima_year_start, clima_year_stop) 40 # Compute anomaly trends
Cell In[8], line 9, in get_annual_precipitation(ds, model) 6 varname = "mtpr" if model == "ERA5" else "pr" 8 # Annual weighted mean ----> 9 da = diagnostics.annual_weighted_mean_timeseries(ds[varname]) 11 # Convert units 12 with xr.set_options(keep_attrs=True):
AttributeError: module 'c3s_eqc_automatic_quality_control.diagnostics' has no attribute 'annual_weighted_mean_timeseries'
I think you are using an old version of the notebook. Make sure you use the latest: https://github.com/bopen/c3s-eqc-toolbox-template/blob/main/notebooks/wp4/trend_pr_cmip6.ipynb
I think we can close this? Feel free to re-open though.
Hi @malmans2
I'm trying to run [trend_pr_cmip6.ipynb] but it looks that "skill_metrics" is not mounted on WP5.
Originally posted by @malmans2 in https://github.com/bopen/c3s-eqc-toolbox-template/issues/52#issuecomment-1540405951