html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue
https://github.com/pydata/xarray/issues/7621#issuecomment-1470494062,https://api.github.com/repos/pydata/xarray/issues/7621,1470494062,IC_kwDOAMm_X85XpfVu,52061672,2023-03-15T17:53:22Z,2023-03-15T17:53:36Z,NONE,"@kmuehlbauer
> The code I provided above (with the fn_NASA_Earthdata_download file) works for you too, but with fn_NSIDC_output it does not?
You are right. I've gone made updates to both the issue description (i.e., the first post) and the Jupyter notebook based on our discussion. So, there might be an issue with the data or the rasterio engine, but for now, we'll use the NetCDF engine for NSIDC data, and hope that someone figures out the problem. Also, thanks for your suggestion on SO; it's much appreciated!","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1622197017
https://github.com/pydata/xarray/issues/7621#issuecomment-1469408924,https://api.github.com/repos/pydata/xarray/issues/7621,1469408924,IC_kwDOAMm_X85XlWac,52061672,2023-03-15T06:19:10Z,2023-03-15T06:19:10Z,NONE,"The post on SO is actually what I wrote. I didn't feel right about messing around with y coordinates, so I came here to figure out what was happening.
Thank you so much for taking the time out of your busy schedule to download the data and test it.
The Xarray Netcdf engine solution worked on my end as well. It was really helpful in exploring what works best for this specific data, where latitude and longitude are stored in different locations. I appreciate your code and will use it for my future processing.
As for the rasterio solution, the output is still flipped along the Y axis. I updated both the rasterio and xarray packages to the latest versions, but the results were still the same. I used the same lines of code that you provided, but with a different file (instead of direct NASA output, I used NSIDC output, as the filename was specified as a variable, fn_NSIDC_output).

","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1622197017
https://github.com/pydata/xarray/issues/7621#issuecomment-1467200120,https://api.github.com/repos/pydata/xarray/issues/7621,1467200120,IC_kwDOAMm_X85Xc7J4,52061672,2023-03-14T01:20:10Z,2023-03-14T01:21:40Z,NONE,"Thank you for checking the code, @kmuehlbauer.
However, I am still experiencing issues even after fixing it.
Regarding the coordinates:
- The y coordinate starts from the maximum values and decreases as you move down the array.
- The latitude values increase with increasing y-coordinate values.
- i.e., The latitude corresponding to the maximum y coordinate is around 85, and the one corresponding to the minimum y coordinate is around -85.


Regarding the precipitation data:
- The structure is the same as the cell_lat/cell_lon array.
- The y coordinate starts from the maximum values and decreases as you move down the array.
- If I plot the precipitation with the xy coordinate, it looks like this, indicating that the data is still inverted. Please refer to these images for further clarification:


Note that the unit is read incorrectly as degrees_north and degrees_east; please ignore it.
Here is the updated code:
```
lons = ds_NSIDC_output_rasterio.cell_lon.load()
lons_array = lons[0][0]
lats = ds_NSIDC_output_rasterio.cell_lat.load()
lats_array = np.arange(lats[0][0][0], lats[0][-1][0], -1*(lats.max().values-lats.min().values)/ds_NSIDC_output.y.size)
ds_NSIDC_output_rasterio_xymanual = xr.DataArray(
data=ds_NSIDC_output_rasterio.precipitation_total_surface_flux.sel(band=1).values,
dims = [""y"",""x""],
coords = dict(
y = lats_array,
x = lons_array.values
)
)
ds_NSIDC_output_rasterio_xymanual.plot()
```

","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1622197017