[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #EXY-306229]: Transforming netCDF 1 D array into 2D array



Hello Ashwin,

You should be able to write your 2d data to the original 1d data arrays using 
`nf_put_vara_real` or `nf_90_put_vara_real` by using the appropriate 'start' 
and 'count' array values.  In regards to reading multiple 1-d arrays into a 
single 2-d array, I don't believe that you can.

I hope this helps,

-Ward


> Hello,
> 
> 
> I am using code similar to this -
> https://github.com/Unidata/netcdf-fortran/blob/master/examples/F90/pres_temp_4D_rd.f90
> to read in latitude and longitude from a netCDF file
> 
> call check( nf_inq_varid(ncid, LAT_NAME, lat_varid) )
> call check( nf_inq_varid(ncid, LON_NAME, lon_varid) )
> 
> ! Read the latitude and longitude data.
> 
> call check( nf_get_var(ncid, lat_varid, lats) )
> call check( nf_get_var(ncid, lon_varid, lons) )
> 
> Both lats and lons are 1-Dimensional fortran arrays.
> 
> My initial data set is in geographical coordinates and I need to convert
> this into a rotated lat lon grid and I use the code in this URL
> https://github.com/thiasB/unrotMe/blob/master/geo2rot.f90
> 
> The way this works is the following For each geographical latitude and
> longitude I get a rotated latitude. Ditto for rotated longitude.
> 
> Mathematically
> 
> f(latitude_geo,longitude_geo) = latitude_rot
> f(latitude_geo,longitude_geo) = longitude_rot
> 
> So the rotated lat and lon arrays are two dimensional arrays. I want to be
> able to write the rotated lat and lon arrays back to the original netCDF
> file using nf_put_vara_real or nf_90_put_vara_real(f77 or f90 does not
> matter).
> 
> How can I do this since the original lat and lon arrays are 1-D arrays ? Is
> it possible to read the original 1-d arrays as 2-D arrays ?
> 
> 
> Regards,
> 
> Ashwin.
> 
> 


Ticket Details
===================
Ticket ID: EXY-306229
Department: Support netCDF
Priority: Normal
Status: Closed
===================
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata 
inquiry tracking system and then made publicly available through the web.  If 
you do not want to have your interactions made available in this way, you must 
let us know in each email you send to us.