Closed akankshabalha closed 11 months ago
Please insert the .ipynb file in the zip (i.e., do not convert to html), otherwise I can't run the notebook to reproduce the error.
The problem is that the variable that you are trying to plot is empty.
For example, print this: quarterly_average_albedo['AL_BH_BB'].shape
Assuming that you are trying to plot da_t2m_regrid_s
, you can just do this:
da_quarterly = da_t2m_regrid_s.groupby("time.season").mean(keep_attrs=True)
plot.projected_map(da_quarterly, col="season", col_wrap=2)
I guess you are trying to do the same for an albedo variable?
You just have to replace da_t2m_regrid_s
with the variable that you want to plot.
To compute seasonal maps, the input variable needs both space and time dimensions as da_t2m_regrid_s
.
Hi @akankshabalha,
Did you get it to work?
Hi, For temperature, the input variable (da_t2m_regrid_s) is working fine. But I am not able to identify appropriate input variable for albedo. I tried 'da_albedo_s' and others. Could you please help me in identifying the same.
The variable you are looking for does not exist in your notebook. Here is an example:
ds = download.download_and_transform(
collection_id_albedo_s,
request_albedo_s,
transform_func=diagnostics.seasonal_weighted_mean,
transform_chunks=False,
split_all=True,
drop_variables=["crs"],
)
plot.projected_map(ds["AL_BH_BB"], col="season", col_wrap=2)
It is giving me seasonal maps of entire big area. But I want to create seasonal maps of subset area. How to do that?
Of course, I sent you a snippet just to get you started.
All you have to do is cutting out the region that you need. Here is another snippet:
ds = download.download_and_transform(
collection_id_albedo_s,
request_albedo_s,
transform_func=diagnostics.seasonal_weighted_mean,
transform_chunks=False,
split_all=True,
drop_variables=["crs"],
)
ds_subset = utils.regionalize(
ds,
lon_slice=slice(77.4, 77.8),
lat_slice=slice(12.8, 13.2),
)
plot.projected_map(ds_subset["AL_BH_BB"], col="season", col_wrap=2)
You already perform the subsetting in your notebook though, so maybe I misunderstood your question?
Yes, I have already performed the subsetting in my notebook. In the last section of code (seasonal maps) in my notebook, I am not able to identify or create a variable for albedo which has both space and time dimension, to be used in place of 'da_albedo_subset_s'. Could you please review my notebook and help me in creating an appropriate variable. I am attaching my nb again for your reference. Albedo_t2m_nb.zip
Did you try the last snippet I sent you? Isn't ds_subset
the variable you are looking for?
@akankshabalha I am reviewing your notebook but something doesn't look right.
You are showing timeseries of different areas in the plots.
The red bars correspond to the temperature in the subset region([13.2, 77.4, 12.8, 77.8]
), whereas the blue lines correspond to the albedo in the overall area ([15, 75, 10, 80]
).
Is this correct or did you want to plot the timeseries corresponding to the same area?
Also, all blue lines (albedo) correspond the spatial weighted std whereas the red bars (temperature) correspond to the spatial weighted mean. Is that correct?
Hi, I created a new template.
Here is the template: https://github.com/bopen/c3s-eqc-toolbox-template/blob/main/notebooks/wp5/urban_heat_islands.ipynb Here is the notebook executed: https://gist.github.com/malmans2/923bbacaa26fb9efcab4d999e6a33b96
There are a few difference compared to your notebook:
Let me know if there's everything you need and/or anything needs to change in the template
Thank you, the notebook looks fine but I think it misses the 'regrid' step as mentioned in my earlier notebook. As the spatial resolution of albedo and temperature dataset is different, I have used regrid function on temperature dataset. Could you please apply regrid function on temperature dataset before creating time-series and seasonal maps.
Following is the code that I used for regridding in my previous notebook:
da_t2m = ds_t2m_maps["t2m"]
plot.projected_map(da_t2m, cmap="YlOrRd")
plt.title("original")
plt.show()
da_t2m_regrid = diagnostics.regrid(
da_t2m, grid_out=da_albedo_subset, method="nearest_s2d"
)
plot.projected_map(da_t2m_regrid, cmap="YlOrRd")
_ = plt.title("regridded")
Also, in the Quarterly time-series plots, it seems difficult to read the x-axis (time-period), (for example, the first vertical bar represents DJF (Dec 1998 - Jan-Feb 1999), however, at first glance, it is not very clear. It appears that the first vertical bar belongs to only year 1998). Is it possible to modify the labels on x-axis in a more clearer way such as first bar has a label of 1998-Dec, second bar - 1999-Mar...?
Thank you, the notebook looks fine but I think it misses the 'regrid' step as mentioned in my earlier notebook. As the spatial resolution of albedo and temperature dataset is different, I have used regrid function on temperature dataset. Could you please apply regrid function on temperature dataset before creating time-series and seasonal maps.
Yes, I mentioned this in my first bullet point . Are you sure that you want to add the interpolation in the notebook? Right now none of the operations in your notebook involve both albedo and temperature maps, so the interpolation is not needed. If you only need to plot the temperature data, original and regridded data using a nearest neighbour algorithm look identical (you noted this yourself here).
Good morning and happy new year!
I've updated the template to address your request about labels.
I also adjusted the extent of the maps. It should be more clear now that a nearest neighbour interpolation would look identical to the plot already shown. Let me know if you still want to add the interpolation step in the notebook.
Here is the template: https://github.com/bopen/c3s-eqc-toolbox-template/blob/main/notebooks/wp5/urban_heat_islands.ipynb Here is the notebook executed: https://gist.github.com/malmans2/923bbacaa26fb9efcab4d999e6a33b96
Thank you very much Mattia for addressing my requests. Happy New Year to you too!
Notebook description
I have calculated monthly and quarterly time-series of albedo and t2m. In the end, I want to create seasonal maps of albedo and t2m, however it is giving an error message shown in the notebook. Albedo_Rev_20Dec.zip
kindly help
Notebook link or upload
No response
Anything else we need to know?
No response
Environment