Open abby-baskind opened 3 years ago
The regridding afterwards will probably not work.
And got this ugly output.
Why ugly? Those look at least pretty consistent? You might end up in the wrong latitude given by how much land is in the North? To check this can you plot a map (of the first time step) of the regridded data? And a printout of the full regridded dataset with dimensions and coordinates?
I think you might need to assign some coordinates to the regridded data. if the values are just logical indicies (0-how long your x-dimension is) then the .sel command will not have the desired results. Fixing that should be relatively easy.
I would agree that it's not necessarily ugly, just something going wrong in the sub selecting of data.
Question: does the regridding work as expected for T and S (and DIC and Alk)? I.e. is this an issue with the regridding, or is it somehow linked to the calculation of a secondary variable (PpCO2)? I would be quite surprised if it were the latter - the PpCO2 calculation should not be doing anything particularly special to the data structures.
If it's not related to the PpCO2 calculation, then this step is adding a layer of complexity that could make the regridding harder to debug.
I thought maybe the x slice I used was wrong, since longitude might not be 0 to 360 and might be -180 to 180 instead. So I changed slice(180, 200) to slice(-160, -180). Admittedly, I might have converted the longitudes wrong.
You could check this directly by looking at the x
coordinate.
Incidentally, you are selecting the longitudes here based on the x
coordinate, as opposed to the 2D longitude array (i.e. what you had previously done with using the .where
command). Is that because the regridded data is on a regular lat-lon grid?
In the meridionalsection
function you are selecting a latitude range (here specified as the xlims
of the axis) between 20 and 160. Clearly these are not the actual latitudes of the data, but more likely the indices, as @jbusecke suggests.
.assign_coords
applied to the dataset(s) or dataarrays will allow you to replace the indices with the actual latitude of the data. Then you should be able to select the appropriate latitudes for plotting.
This is likely also the case for the longitude dimension (the y
dimension).
Disclaimer: This is a very chaotic issue because getting the
gn
models to work is taking a backseat to making my presentation right now. I probably could have tried to debug better, but I mostly needed to post the issue before I forgot.So I'm trying to plot meridional slices of PpCO2 for the
gn
models I regridded, like I did for the 'gr' models. This is thegr
output I'm trying to replicate withgn
.I regridded the
gn
models like this...And I calculated PpCO2 with these functions.
I tried a few different ways. First, I tried plotting the models after they had been regridded like this
And got this ugly output.
I thought maybe the x slice I used was wrong, since longitude might not be 0 to 360 and might be -180 to 180 instead. So I changed
slice(180, 200)
toslice(-160, -180)
. Admittedly, I might have converted the longitudes wrong.But the output was even worse
so then I tried plotting PpCO2 without regridding
The output was questionable
But then I tried regridding after I calculated PpCo2
And got this error
And it makes sense that the shapes don't match since I'm averaging over x, but I don't know how to fix it. I'm also not fully convinced that changing the shape of the regridder or
pco2
will fix the issue