Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert a rotated NetCDF back to a normal lat/lon grid?

I have a NetCDF file with rotated coordinates. I need to convert it to normal lat/lon coordinates (-180 to 180 for lon and -90 to 90 for lat).

library(ncdf4)
nc_open('dat.nf')

For the dimensions, it shows:

[1] "     5 variables (excluding dimension variables):"
[1] "        double time_bnds[bnds,time]   "
[1] "        double lon[rlon,rlat]   "
[1] "            long_name: longitude"
[1] "            units: degrees_east"
[1] "        double lat[rlon,rlat]   "
[1] "            long_name: latitude"
[1] "            units: degrees_north"
[1] "        char rotated_pole[]   "
[1] "            grid_mapping_name: rotated_latitude_longitude"
[1] "            grid_north_pole_longitude: 83"
[1] "            grid_north_pole_latitude: 42.5"
[1] "        float tasmax[rlon,rlat,time]   "
[1] "            long_name: Daily Maximum Near-Surface Air Temperature"
[1] "            standard_name: air_temperature"
[1] "            units: K"
[1] "            cell_methods: time:maximum within days time:mean over days"
[1] "            coordinates: lon lat"
[1] "            grid_mapping: rotated_pole"
[1] "            _FillValue: 1.00000002004088e+20"

[1] "     4 dimensions:"
[1] "        rlon  Size:310"
[1] "            long_name: longitude in rotated pole grid"
[1] "            units: degrees"
[1] "            axis: X"
[1] "            standard_name: grid_longitude"
[1] "        rlat  Size:260"
[1] "            long_name: latitude in rotated pole grid"
[1] "            units: degrees"
[1] "            axis: Y"
[1] "            standard_name: grid_latitude"
[1] "        bnds  Size:2"

Could anyone show me how to convert the rotated coordinates back to normal lat/lon? Thanks.

like image 728
user1617676 Avatar asked Jul 21 '15 21:07

user1617676


2 Answers

NCO's ncks can probably do this in two commands using MSA

ncks -O -H --msa -d Lon,0.,180. -d Lon,-180.,-1.0 in.nc out.nc ncap2 -O -s 'where(Lon < 0) Lon=Lon+360' out.nc out.nc

like image 119
Charlie Zender Avatar answered Sep 16 '22 21:09

Charlie Zender


I would use cdo for this purpose https://code.zmaw.de/boards/2/topics/102

Another option is just create a mapping between rotated and geographic coordinates and use the original data without interpolation. I can find the equations if necessary.

like image 43
kakk11 Avatar answered Sep 18 '22 21:09

kakk11