Project

General

Profile

cdo: remapping Geostationary Grid into lonlat grid

Added by Tahmida Sarker Muna 7 months ago

I am lost while trying to remap CM SAF CLoud property Instantaneous (CTXin20240420234500405SVMSGI1MD.nc) dataset into lat/long based projection.

The data currently has whole globe observation (METEOSAT disk). I want to remap it into geographic coordinate system based netCDF. I am trying to remap using the projection information from provided Auxiliary data (https://wui.cmsaf.eu/safira/action/viewDoiDetails?acronym=CLAAS_V003). I retrieved the projection information from the auxiliary file to a .gdr file (00_Class3.grd). Then using this command for remapping.

$ cdo remapbil,00_Class3.grd, CTXin20240420234500405SVMSGI1MD.nc 00CTXin202404202345.nc

but its showing this output

cdo    remapbil (Abort): Too many arguments! Need 1 found 2.

This is my first time using linux & cdo for processing such data. Am I missing something in the processing? It would be great if any kind soul can help me with it.

Projection information from the data:

gridID 1

gridtype = projection
gridsize = 13778944
xsize = 3712
ysize = 3712
xname = x
xlongname = "x coordinate of projection"
xunits = "radian"
yname = y
ylongname = "y coordinate of projection"
yunits = "radian"
xfirst = -0.155613222592103
xinc = 8.38433311379864e-05
yfirst = 0.155613222592103
yinc = -8.38433311379864e-05
scanningMode = 64
grid_mapping = projection
grid_mapping_name = geostationary
long_name = "projection information"
perspective_point_height = 35785831.
latitude_of_projection_origin = 0.
longitude_of_projection_origin = 0.
sweep_angle_axis = "y"
semi_minor_axis = 6356583.8
semi_major_axis = 6378169.

gridID 2

gridtype = generic
gridsize = 1
scanningMode = 64

Projection information from the Auxiliary data:

gridID 1
gridtype = lonlat
gridsize = 12960000
xsize = 3600
ysize = 3600
xname = lon
xlongname = "Longitude"
xunits = "degrees_east"
yname = lat
ylongname = "Latitude"
yunits = "degrees_north"
xfirst = -89.975
xinc = 0.05
yfirst = -89.975
yinc = 0.05
scanningMode = 64


Replies (5)

RE: cdo: remapping Geostationary Grid into lonlat grid - Added by Karin Meier-Fleischer 7 months ago

The CTX file contains coordinates with units in radians, therefore you need a gridfile for the CTX input file like

gridfile.txt

#
# gridID 1
#
gridtype  = projection
gridsize  = 13778944
xsize     = 3712
ysize     = 3712
xname     = x
xlongname = "x coordinate of projection" 
xunits    = "radian" 
yname     = y
ylongname = "y coordinate of projection" 
yunits    = "radian" 
xfirst    = -0.155613222592103
xinc      = 8.38433311379864e-05
yfirst    = 0.155613222592103
yinc      = -8.38433311379864e-05
grid_mapping = projection
grid_mapping_name = geostationary
long_name = "projection information" 
perspective_point_height = 35785831.
latitude_of_projection_origin = 0.
longitude_of_projection_origin = 0.
sweep_angle_axis = "y" 
semi_minor_axis = 6356583.8
semi_major_axis = 6378169.
proj_params = "+proj=geos +h=35785831.0 +lon_0=0.r +lat_0=0.r +a=6378169. +b=6356583.8 +sweep=y +no_defs" 
#
# gridID 2
#
gridtype  = generic
gridsize  = 1

Then try (this takes a long time):

cdo -P 8 -remapnn,claas3_level3_aux_data_005deg.nc -setgrid,g.txt CTXin20240420234500405SVMSGI1MD.nc outfile.nc

RE: cdo: remapping Geostationary Grid into lonlat grid - Added by Tahmida Sarker Muna 7 months ago

I tried with your suggestion. But now it's showing

cdo(1) setgrid (Abort): xsize undefined

00_grid.txt.txt (848 Bytes) 00_grid.txt.txt grid file txt

RE: cdo: remapping Geostationary Grid into lonlat grid - Added by Tahmida Sarker Muna 7 months ago

Apologies. Its on the run. It was showing that because of one of my typo.

Another follow up query!
I literally have around 100 such files which I need to remap in such way. Is it possible to make a loop over here? Any tips for quicker processing?

RE: cdo: remapping Geostationary Grid into lonlat grid - Added by Miles Sowden 5 months ago

I have been trying for about 6 years to get this issue resolved. Best fix so far is to use gdal.It only works on one parameter at a time and you need to reset all attributes. here is some test code I use that you are welcome to adapt.

#!/bin/bash

# Reproject data
echo "Starting reprojection of data..." 
for f in dX_2019121000_B*.nc; do
    base=$(basename "$f" .nc)
    echo "Reprojecting $base..." 
    gdalwarp -t_srs EPSG:4326 -te 85 -45 160 50 -tr 0.02 0.02 -r cubic "$f" wgs_${base}.nc &
done
wait
echo "Reprojection complete." 

# Translate to NetCDF
echo "Translating reprojected files to NetCDF..." 
for f in wgs_dX_2019121000_B*.nc; do
    base=$(basename "$f" .nc | sed 's/^wgs_//')
    gdal_translate -of netCDF -a_srs EPSG:4326 wgs_${base}.nc "${base}.nc" 
done
wait
echo "Translation complete." 

# Rename variable names and set properties
echo "Setting variable names and time for reprojected files..." 
for f in dX_2019121000_B*.nc; do
    base=$(basename "$f" .nc)
    param_name=$(echo $base | cut -d'_' -f3) # Extracts B07, BTD14_15, etc.
    echo "Setting variable name for $base to $param_name..." 
    ncrename -v Band1,$param_name "${base}.nc" 
    time_val=$(date -d "2019-12-10 00:00:00" +%s)
    ncap2 -O -s "defdim(\"time\",1); time[time]=$time_val" "${base}.nc" "${base}.nc" 
    ncatted -O -a units,time,o,c,"seconds since 1970-01-01 00:00:00" -a reftime,time,o,c,"2019-12-10 00:00:00" "${base}.nc" 
done
echo "Variable names and properties set." 

RE: cdo: remapping Geostationary Grid into lonlat grid - Added by Ralf Mueller 5 months ago

thx for posting your workaround, Miles ;-)

cheers
ralf

    (1-5/5)