Re: How to copy the metadata from one NetCDF to another

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Thu, 11 Jan 2007 14:10:26 -0700 (MST)

FYI: Your netCDF file "O3.lyr1.2001152.nc"
     has *no* coordinate variables as defined by netCDF.
     By Unidata/netCDF definition, a coordinate variable
     is a *one* dimensional array of monotonically
     {in/de}creasing numeric values.
     
     The data on your file do not conform to any common
     netCDF convention [eg: COARDS or CF].
     
As a new user, I suggest that you use "printVarSummary"
frequently.

     
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"

   xTemp = x(LAY|:, ROW|:, COL|:,TSTEP|:)
   xMaxTime = dim_max( xTemp )
   print("==================")
   printVarSummary( xMaxTime )
   

   copy_VarMeta (xTemp, xMaxTime)
   print("==================")
   printVarSummary( xMaxTime )
   
   
   print("==================") ; alter the long_name
   xMaxTime_at_long_name = "Daily max: "+ xMaxTime_at_long_name
   printVarSummary( xMaxTime )
  
   
   system("rm -f dailyout.nc") ; remove any previous file
   fout_dailymax = addfile("dailyout.nc" , "c")
   fout_dailymax_at_TITLE = "DAILY MAXIMUM O3"
   fileattdef( fout_dailymax , f ) ; copy file attributes
   fout_dailymax->O3 = xMaxTime ; (LAY,ROW,COL)

I do not know what PAVE is.
I do not know what it is looking for.
It looks to me like you have gewgraphical information in
your file attributes. Perhaps, a code for map projection?

  res_at_gsnAddCyclic = False ; regional data: not cyclic
  res_at_tfDoNDCOverlay = True ; set True for native projection

  res_at_mpProjection = "LambertConformal" ; ??????
  res_at_mpLambertParallel1F = f_at_TRUELAT1 ; P-ALP ?
  res_at_mpLambertParallel2F = f_at_TRUELAT2 ; P_BET ?
  res_at_mpLambertMeridianF = f_at_CEN_LON
  res_at_mpLimitMode = "Corners"
  res_at_mpLeftCornerLatF = ; define sub-domain
  res_at_mpLeftCornerLonF =
  res_at_mpRightCornerLatF =
  res_at_mpRightCornerLonF =

  res_at_tiMainString = f_at_CDATE ; ?SDATE ?WDATE
 

function description:
 
http://www.ncl.ucar.edu/Document/Functions/Contributed/copy_VarMeta.shtml
http://www.ncl.ucar.edu/Document/Functions/Built-in/printVarSummary.shtml

>Thanks very much
>
>I got the daily maximum from the NetCDF containing the hourly data.
>I generated a new NetCDF file based on the daily maximum.
>I am wondering if I can copy the metadata from the original NetCDF to
>the new daily maximum NetCDF?
>I can use PAVE to plot the original NetCDF file. But for the new daily
>maximum NetCDF PAVE said
>"ncattget: ncid 6: Attribute not found
>invalid data set
>Can't use dataset '/***************"
>
>The way I generate the daily maximum NetCDF is
>"
>f = addfile (fnames(nf)+".nc", "r")
>fout_dailymax = addfile("dailyout.nc" , "c")
>x = f->O3
>xMaxTime = dim_max( x(LAY|:, ROW|:, COL|:,TSTEP|:) )
> fout_dailymax->O3=xMaxTime"
>
>I also attached the meta data of the original NetCDF file.
>I guess PAVE need the meta data to generate the background map.
>So I am wondering how to copy those meta data to my new daily maximum
>NetCDF, then I can use PAVE to plot.
>
>Sorry for my broken English
>
>Thanks very much
>
>Xiaoming
>
>
>
>
>
>Dennis Shea wrote:
>> Use:
>>
>> xMaxTime = dim_max( x(LAY|:, ROW|:, COL|:,TSTEP|:) )
>>
>> The {...} are for use in coordinate subscripting.
>> You are using named dimensions to reorder.
>>
>>
>>
>>> I met the problem with "coordinate variable" when post processing CMAQ
>>> output.
>>>
>>> I want to get the daily maximum of ozone concentration.
>>>
>>> My script is below
>>>
>>> ;************************************************
>>> x = f->O3 ; (Time, bottom_top, south_north, west_east)
>>> dims = getfilevardims(f,"O3")
>>> printVarSummary(x)
>>> print (dims)
>>> ;************************************************
>>> ; Get daily 1hr maximum
>>> ;************************************************
>>> xMaxTime = dim_max( x(LAY|:, {ROW|:}, {COL|:},{TSTEP|:}) )
>>>
>>>
>>>
>>> The output on the screen is
>>>
>>> Variable: x
>>> Type: float
>>> Total Size: 1784832 bytes
>>> 446208 values
>>> Number of Dimensions: 4
>>> Dimensions and sizes: [TSTEP | 24] x [LAY | 1] x [ROW | 112] x [COL | 166]
>>> Coordinates:
>>> Number Of Attributes: 3
>>> long_name : O3
>>> units : ppmV
>>> var_desc : Variable O3
>>>
>>>
>>> Variable: dims
>>> Type: string
>>> Total Size: 16 bytes
>>> 4 values
>>> Number of Dimensions: 1
>>> Dimensions and sizes: [4]
>>> Coordinates:
>>> (0) TSTEP
>>> (1) LAY
>>> (2) ROW
>>> (3) COL
>>> fatal:Dimension (TSTEP) of (x) does not have an associated coordinate
>>> variable
>>> fatal:Execute: Error occurred at or near line 33
>>>
>>>
>>>
>>> Any help will be greatly appreciated.
>>>
>>> Xiaoming
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk_at_ucar.edu
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>
>>
>>
>

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Jan 11 2007 - 14:10:26 MST

This archive was generated by hypermail 2.2.0 : Tue Jan 16 2007 - 14:49:44 MST