Re: regrid from ascii text

From: Maria Gehne - NOAA Affiliate <maria.gehne_at_nyahnyahspammersnyahnyah>
Date: Tue Jun 10 2014 - 13:54:22 MDT

Hi Marc,

I'm not sure I understand what exactly you are trying to do. Do you want to
read in the ascii data and turn it into a 2D array with lat and lon
dimension attached? In order to do that you need to know how the data was
written in you ascii file (i.e. lat values first or lon values first). Once
you know that you can read in the whole ascii file using

data1D = asciiread("asciifile",-1,"float")

(assuming your data format is float, otherwise replace with the correct
format).

Then you can use the onedtond function to turn the 1D array into your 2D
array:

data = onedtond(data1D,(/nlat,nlon/))

or

data = onedtond(data1D,(/nlon,nlat/))

depending on how your data was written.

After that you just need to attach the dimension arrays lat and lon:

data!0 = "lat"
data&lat = lat
data!1 = "lon"
data&lon = lon

Note: this assumes your ascii file only contains one time step (you didn't
say if it has one or more). If you have more than one you need to figure
out how many time steps are in the file. How they were written (all lat/lon
values for one time step together and then the next time step?) And then
you can make a 3D array of size (/ntim,nlat,nlon/) by looping through the
number of time steps for example.


Hope this helps,

Maria







On Mon, Jun 9, 2014 at 2:57 PM, Marcella, Marc <MMarcella@air-worldwide.com=
>
wrote:

> Hi all,
>
>
>
> I have an ascii file that was basically written out from a 1km gridded
> dataset to this said text file. I am trying to “reconstructâ€=
ť the data and
> put it back on a 2D grid. The text file has the corresponding (1D arrays=
)
> for lat and lon values at 1km resolution and the corresponding data value
> at that point. What is the best technique to put this back on a 2d grid?
> I tried following the ESMF_regrid data example for “unstructured=
” data, but
> the results look a little bit off (i.e. the regrid fills in the data for
> locations where the value should be NaN which subsequently “stret=
ches” the
> data). Is there another simple yet better approach to take this data and
> place it on a regular grid to map in NCL?
>
>
>
> Thank you for the help in advance!
>
>
>
> Marc
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>

Received on Tue Jun 10 07:54:54 2014

This archive was generated by hypermail 2.1.8 : Wed Jul 23 2014 - 15:33:46 MDT