Re: how to copy global attributes from one netCDF file to another

From: Karin Meier-Fleischer <meier-fleischer_at_nyahnyahspammersnyahnyah>
Date: Mon May 19 2014 - 05:30:44 MDT

Hi Basit,

first you have to read all global attributes from your input file and
afterwards write it to the new file:

begin

;-- open files
   f = addfile("input_data.nc","r") ;-- input data file

   system("rm -rf global_att_test.nc") ;-- delete file
   g = addfile("global_att_test.nc","c") ;-- create new
netcdf file

   global_attnames = getvaratts(f) ;-- retrieve the
global attributes from input file

   do i=0,dimsizes(global_attnames)-1
      print(f@$global_attnames(i)$) ;-- print global
attribute contents
      g@$global_attnames(i)$ = f@$global_attnames(i)$ ;-- write global
attributes to new file
   end do

end

Bye,
Karin

Am 19.05.14 13:03, schrieb BasitAli Khan:
> Hi ncl folks,
>
> I want to copy global attributes from WRF netCDF file to another
> netCDF file created using addfile .... 'c' option. I don't think i
> can use fileattdef() function because to use this function i would
> need to define global attributes that is what i don't want to do. I
> would greatly appreciate if anyone could help me in this.
>
> Many thanks in advance,
>
> b:)
> ----
>
> Basit A. Khan, Ph.D.
>
> Postdoctoral Research Fellow
>
> Division of Physical Sciences & Engineering
>
> Office# 3204, Level 3, Building 1,
>
> King Abdullah University of Science & Technology
>
> 4700 King Abdullah Blvd, Box 2753, Thuwal 23955 --6900,
>
> Kingdom of Saudi Arabia.
>
> Office: +966(0)12 808 0276, Mobile: +966(0)5 0860 3617
>
> E-mail: basitali.khan@kaust.edu.sa <mailto:basitali.khan@kaust.edu.sa>
>
> Skype name: basit.a.khan
>
> ------------------------------------------------------------------------
>
> This message and its contents including attachments are intended
> solely for the original recipient. If you are not the intended
> recipient or have received this message in error, please notify me
> immediately and delete this message from your computer system. Any
> unauthorized use or distribution is prohibited. Please consider the
> environment before printing this email.
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
Dipl. Geophys. Karin Meier-Fleischer
Application Support, Visualization
Deutsches Klimarechenzentrum GmbH      E-Mail:   meier-fleischer@dkrz.de
Bundesstrasse 45a                      Internet: http://www.dkrz.de/
20146 Hamburg                          Phone:    +49 (0)40 460094 126
Germany                                Fax:      +49 (0)40 460094 270
Geschäftsführer: Prof. Dr. Thomas Ludwig
Sitz der Gesellschaft: Hamburg
Amtsgericht Hamburg HRB 39784

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon May 19 05:31:03 2014

This archive was generated by hypermail 2.1.8 : Tue May 20 2014 - 10:18:04 MDT