[ncl-talk] or_extracted_ocean_data
Dennis Shea
shea at ucar.edu
Tue Jun 13 08:42:26 MDT 2017
I have no idea why you would want ascii file(s). ASCII is the least
efficient method of storage.
https://www.ncl.ucar.edu/Document/Functions/Built-in/sprintf.shtml
https://www.ncl.ucar.edu/Document/Functions/Built-in/asciiwrite.shtml
You may have to alter the format for the variable. Please read the sprintf
documentation.
nval = num(.not.ismissing(data)) ; number of
non-missinf values
data_str = new(nval,"string","No_FillValue") ; array for strings
; crudest/simplest/least-efficient method
; group by time
nv = -1
do nt=0,ntim-1
do nl=0,nlat-1
do ml=0,mlon-1
if (.not.ismissing(data(nt,nl,ml))) then
nv = nv+1
data_str(nv) = sprintf("%10.3f", data&time(nt)) \
+ sprintf("%7.3f" , data&lat(nl))
\
+ sprintf("%7.3f" , data&lon(ml))
\
+ sprintf("%7.3f" ,
data(nt,nl,ml) )
end if ; .not.(ismissing())
end do ; ml
end do ; nl
end do ; nt
diro = "./"
filo = "SST.txt"
ptho = diro+filo
* asciiwrite( ptho, data_str)*----------------------------
You may want to alter the order. For each grid point, a time series.
Group by grid point
do nl=0,nlat-1
do ml-0,mlon-1
do nt=0,ntim-1
On Tue, Jun 13, 2017 at 3:56 AM, Kunal Bali <kunal.bali9 at gmail.com> wrote:
> Dear NCL user
>
> I have masked the ocean data. Now I am trying to extract the ocean data
> only.
> So, how to extracted ASCII file of data_ocean_only variable in the given
> code below.
>
> please provide some information that.
>
> Thank You
>
> begin
> ;---Read data
> dir = "/home/kunal/mishra_sir/"
> fnames = systemfunc("ls " + dir + "DAY_*.nc")
> a = addfiles(fnames,"r")
> mfile = addfile("/usr/local/lib/ncl/lib/ncarg/data/cdf/
> landsea.nc","r")
> data = a[:]->sshf
> data = data/100000
>
> lsmask = mfile->LSMASK
> lsm = landsea_mask(lsmask,data&latitude,data&longitude)
>
> data_ocean_only = mask(data,lsm.eq.0,True)
> copy_VarMeta(data,data_ocean_only)
>
> printVarSummary (data)
>
> end
>
> file detained is given as
>
> Variable: data
> Type: float
> Total Size: 938060 bytes
> 234515 values
> Number of Dimensions: 3
> Dimensions and sizes: [time | 31] x [latitude | 85] x [longitude | 89]
> Coordinates:
> time: [983223..983943]
> latitude: [25.5..15]
> longitude: [59..70]
> Number Of Attributes: 4
> standard_name : surface_upward_sensible_heat_flux
> long_name : Surface sensible heat flux
> units : J m**-2
> _FillValue : -32767
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170613/77a6856e/attachment.html
More information about the ncl-talk
mailing list