最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

invert latitude from -90,90 to 90,-90 in a netcdf file - Stack Overflow

programmeradmin0浏览0评论

I have the following netcdf file: ncfile.nc

The file has latitudes ranging from -90deg to 90deg.

I need to flip these coordinates to 90deg, -90deg, so that the southern hemisphere becomes the northern hemisphere and viceversa.

I tried with cdo invertlat but it does not work.

Any suggestion?

I have the following netcdf file: ncfile.nc

The file has latitudes ranging from -90deg to 90deg.

I need to flip these coordinates to 90deg, -90deg, so that the southern hemisphere becomes the northern hemisphere and viceversa.

I tried with cdo invertlat but it does not work.

Any suggestion?

Share Improve this question edited Feb 9 at 9:25 aaaaa asked Feb 6 at 20:39 aaaaaaaaaa 1832 gold badges20 silver badges48 bronze badges 4
  • Ps: "it doesn't work" is never very helpful, usually best to post what what wrong, the error message or what the command does. :-) and pps: the file you posted doesn't seem to be a netcdf file – ClimateUnboxed Commented Feb 6 at 22:17
  • @ClimateUnboxed The file is a netCDF file and I can open it without problem. Perhaps a tad unconventional in the extension though... The data variable is called "var" and is GRIB id 129, Geopotential, originally produced by ECMWF. The "history" global attribute is "cdo -0 setattribute,history=", i.e. delete the history. Not much to go by then. – Patrick Commented Feb 7 at 8:34
  • Weird. I hit the download on your link changed the extension to .nc and ncview wouldn't open it. Or ncdump. Glad to see the NCO suggestion put you on the right track, hope it wasn't you thanking me for it with the down vote , wouldn't be very appreciative. – ClimateUnboxed Commented Feb 7 at 15:20
  • @ClimateUnboxed No, that downvote wasn't mine but neither am I the OP, just an interested citizen. I used R package ncdfCF, perhaps you should return to the warm embrace of R and give it a try? – Patrick Commented Feb 7 at 18:13
Add a comment  | 

2 Answers 2

Reset to default 2

The answer from @aaaaa may work, though I cannot see quite how it reorders the values. I suggest a hybrid of that and Adrian's answer:

ncap2 -s 'lat=-lat;' in.nc temp.nc # Change [-90,0] to [90,0]
ncpdq --reorder=-lat temp.nc out.nc # Reverse [90,0] to [0,90]

Documentation is here.

The form give by Adrian @ClimateUnboxed above will reverse the latitudes so they go from 0 to -90, but only for the lat coordinate, which it places alone in the output file. And the values will still be [0,-90], not [0,90] as desired.

this works:

ncap2 -s 'lat=-lat;' ncfile.nc out.nc 

it multiplies the original latitude values by -1

发布评论

评论列表(0)

  1. 暂无评论