Re: addfile() for create new nc file

From: gibies george <gibies_at_nyahnyahspammersnyahnyah>
Date: Wed Aug 10 2011 - 02:29:36 MDT

Thank you Dennis and Mary for your support and suggestions.

My problem is solved by doing a slight variation in my script according to
your suggestions. Some how I had to retain the string information and so I
made it to an attribute to the data variable. But I still feel it is better
to have more direct way to do all these things. Please inform me if there is
some simpler way.

Thanking you once again

*Here is my modified script.*
________________________________________________________________________________________________

multidata =
new((/dimsizes(time),dimsizes(lat),dimsizes(lon),dimsizes(season),dimsizes(component),\
nofens,nofmdls/),float)
multidata!0 = "time"
multidata&time = time
multidata!1 = "lat"
multidata&lat = lat
multidata!2 = "lon"
multidata&lon = lon
multidata!3 ="season"
multidata&season=ind(.not.ismissing(season))
multidata@season = season
multidata!4 ="component"
multidata&component=ind(.not.ismissing(component))
multidata@component = component
multidata!5 ="ens"
multidata&ens = ispan(1,nofens,1)
multidata@ens = ens
multidata!6 ="mdl"
multidata&mdl = ispan(1,nofmdls,1)
multidata@mdl = mdl
-------------------
-----------
----------------------
----------
multidata@dataset = mdl@analdset + "_" + predef@anal_start_year + "_to_" +
predef@anal_end_year
multidata@datavar = datavar
multidata&ens = ind(.not.ismissing(ens))
multidata&mdl = ind(.not.ismissing(mdl))
print("---------------Multimodel Ensemble-------------------")
print("_____________________________________________________")
printVarSummary(multidata)
print("_____________________________________________________")

  syout= systemfunc("rm " + mdl@analdset+"_multimodel_data.nc")
outfile = addfile(mdl@analdset+"_multimodel_data.nc","c")
outfile->multi_model_data = multidata
print("Data is written. Press any key to continue.")
response = systemfunc("read var; echo $var")
___________________________________________________________________________________________

*
*
*Here is the output.*

Variable: multidata
Type: float
Total Size: 12960000 bytes
            3240000 values
Number of Dimensions: 7
Dimensions and sizes: [time | 25] x [lat | 180] x [lon | 360] x [season | 1]
x [component | 1] x [ens | 2] x [mdl | 1]
Coordinates:
            time: [1981..2005]
            lat: [-90..90]
            lon: [ 0..360]
            season: [0..0]
            component: [0..0]
            ens: [0..1]
            mdl: [0..0]
Number Of Attributes: 22
  unit : mm/day
  units : mm/day
  long_name : _rain
  nosclr : 1
  novctr : 0
  mpCenterLonF : 180
  loneast : 360
  lonwest : 0
  latnorth : 90
  latsouth : -90
  anal_end_year : 2005
  anal_start_year : 1981
  datavar : _rain
  dataset : cfsv2_jjas_1981_to_2005
  ssnbegin : 6
  ssnend : 9
  region : global
  mdl : cfsv2
  ens : ( feb_initial , may_initial )
  component : rain
  season : jjas
  _FillValue : -9.96921e+36
(0) _____________________________________________________
(0) Data is written. Press any key to continue.

____________________________________________________________________________________________

On 6 June 2011 21:53, Mary Haley <haley@ucar.edu> wrote:

>
> Hi,
>
> NetCDF doesn't allow you to have strings for coordinate arrays. You must
> convert these to 2D character arrays.
>
> Please see the "Coordinate Systems" section of this NetCDF document:
>
> http://www.unidata.ucar.edu/software/netcdf/docs/BestPractices.html
>
> I don't know how you created "season" in your code below, but you can try
> converting it to a character array, and use this as your coordinate
> variable:
>
> cseason = tocharacter(season)
> multidata&season = cseason
>
> --Mary
>
> On Jun 6, 2011, at 1:11 AM, gibies george wrote:
>
> Dear NCL users,
>
> Somebody please suggest a way to eliminate the following warning messages.
>
> I was trying to write my dataset to an nc file.
>
> Thanking you in davance.
>
> *_______________________________________
> ________________Script__________________
> _______________________________________*
> -------------------------
> -----------------------
> ----------------------------
> ---------------------
> --------------------------
>
> multidata@dataset = mdl@analdset + "_" + predef@anal_start_year +
> "_to_" + predef@anal_end_year
> multidata@datavar = datavar
> multidata&ens = ens
> multidata&mdl = mdl
> print("---------------Multimodel Ensemble-------------------")
> print("_____________________________________________________")
> printVarSummary(multidata)
> print("_____________________________________________________")
>
> syout= systemfunc("rm " + mdl@analdset+"_multimodel_data.nc")
> outfile = addfile(mdl@analdset+"_multimodel_data.nc","c")
> outfile->multi_model_data = multidata
>
> return(multidata)
> end ;;; End of function definition get_multimodel_data() ;;;
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> *_______________________________________*
>
> *_________________________________
> ___________ Output _______________
> _________________________________*
>
>
> (0) ---------------Multimodel Ensemble-------------------
> (0) _____________________________________________________
>
>
> Variable: multidata
> Type: float
> Total Size: 272160000 bytes
> 68040000 values
> Number of Dimensions: 7
> Dimensions and sizes: [time | 25] x [lat | 280] x [lon | 360] x [season
> | 1] x [component | 3] x [ens | 1] x [mdl | 9]
> Coordinates:
> time: [1981..2005]
> lat: [-35..35]
> lon: [30..120]
> season: [ond..ond]
> component: [rain..tsfc]
> ens: [..]
> mdl: [cfsv2_jun_init..DePreSys_UKMO_aug_init]
> Number Of Attributes: 18
> unit : ( mm/day, hPa, degC )
> units : ( mm/day, hPa, degC )
> region : indotropic
> ssnend : 12
> ssnbegin : 10
> dataset : ond_skill_1981_to_2005
> datavar : _rain_mslp_tsfc
> anal_start_year : 1981
> anal_end_year : 2005
> latsouth : -35
> latnorth : 35
> lonwest : 30
> loneast : 120
> mpCenterLonF : 75
> novctr : 0
> nosclr : 3
> long_name : _rain_mslp_tsfc
> _FillValue : -9.96921e+36
> (0) _____________________________________________________
> fatal:Attempting to write variable (season) of type (string) which is not
> representable in the format of file (ond_skill_multimodel_data.nc)
> fatal:Trying using a type conversion function
> warning:FileWriteVarVar: Could not write coordinate variable (season) to
> file (ond_skill_multimodel_data), continuing anyway
> fatal:Attempting to write variable (component) of type (string) which is
> not representable in the format of file (ond_skill_multimodel_data.nc)
> fatal:Trying using a type conversion function
> warning:FileWriteVarVar: Could not write coordinate variable (component) to
> file (ond_skill_multimodel_data), continuing anyway
> fatal:Attempting to write variable (ens) of type (string) which is not
> representable in the format of file (ond_skill_multimodel_data.nc)
> fatal:Trying using a type conversion function
> warning:FileWriteVarVar: Could not write coordinate variable (ens) to file
> (ond_skill_multimodel_data), continuing anyway
> fatal:Attempting to write variable (mdl) of type (string) which is not
> representable in the format of file (ond_skill_multimodel_data.nc)
> fatal:Trying using a type conversion function
> warning:FileWriteVarVar: Could not write coordinate variable (mdl) to file
> (ond_skill_multimodel_data), continuing anyway
> warning:Execute: Error occurred at or near line 3188 in file
> /home/gibies/ncl/mylib/lib_gibies_read_data_module.ncl
>
>
>
> --
> *Gibies George, CSIR-RF,*
> *Monsoon Seasonal Prediction Group,
> Climate and Global Modelling Division,
> Indian Institute of Tropical Meteorology,
> Dr. Homi Bhabha Road,
> NCL (P. O.), Pashan,
> Pune 411008, India.*
>
> *http://sites.google.com/site/gibiesge/*
>
> Please Think about the environment. Save paper; Save Trees; and don't print
> this e-mail unless it is necessary.
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>

-- 
*Gibies George,   CSIR-RF,*
*Monsoon Seasonal Prediction Group,
Climate and Global Modelling Division,
Indian Institute of Tropical Meteorology,
Dr. Homi Bhabha Road,
NCL (P. O.), Pashan,
Pune 411008, India.*
*http://sites.google.com/site/gibiesge/*
Please Think about the environment. Save paper; Save Trees; and don't print
this e-mail unless it is necessary.

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Aug 10 02:29:48 2011

This archive was generated by hypermail 2.1.8 : Mon Aug 22 2011 - 08:13:37 MDT