[gradsusr] How to get four variables to a single output file...????

Jennifer Adams jma at cola.iges.org
Mon Oct 7 09:53:46 EDT 2013


This question and similar variants comes up so often, I have finally written a documentation page about importing/exporting ASCII data. 
Please see http://iges.org/grads/gadoc/ascii.html. This page is linked to from the headings "ASCII data" and "text data" in the documentation index. At the moment, the examples are all based on gridded data. The fprintf.gs script in the opengrads cookbook is quite similar to example #2 in the doc page. The third example takes it a bit further and shows you how to do what you are asking here. 
--Jennifer

On Oct 6, 2013, at 8:51 PM, Muhammad Yunus Ahmad Mazuki wrote:

> Because you can combine string operands, You can combine the four variables that were in different operands into one operands, and print that whole string instead. Something like:
> 
> line.1=xlat.1+' '+x.lon.1+' 'temp.1+' 'ppt.1
> 
> Be sure to leave appropriate separator like spaces, or commas, depending whether you want to save in binary, text or csv.
> 
> 
> On Mon, Oct 7, 2013 at 6:56 AM, Andrew Friedman <andfried at berkeley.edu> wrote:
> Hi Uzair,
> 
> I don't think that fprintf alone can make what you're looking for.
> 
> I haven't done this, but two possible approaches come to mind:
> 1. You can combine the output of different variables from fprintf using an external text processing utility such as awk.
> 2. You can create a table from netcdf data directly using the NCO (netcdf operator) ncks:
> http://nco.sourceforge.net/nco.html#ncks-netCDF-Kitchen-Sink (see section 4.7.1: Filters for ncks)
> 
> Can you describe more what you're using the table for? Others may be able to help with a better understanding of the specifics.
> 
> Andrew
> 
> 
> On Oct 6, 2013, at 10:18 AM, uzair manan <uzair_july at hotmail.com> wrote:
> 
> > GOOD MORNING EVERYONE:
> >
> > I've simulated global data using a regional climate model.. The output it generates is in netcdf format. The output file contains four variables which are :-
> > 1. Latitude (xlat)
> > 2. Longitude (xlon)
> > 3. Temperature (temp)
> > 4. Precipitation (ppt)
> >
> > Now how can I generate, using fprintf or any other way, a single file that contains a template as shown below:- (FOR EXAMPLE)
> >
> > LATITUDE              LONGITUDE                  TEMPERATURE             PRECIPITATION
> >
> >     23                                 60                                       23                                        10mm
> >     23.5                              60.5                                    26                                        26mm
> >       .                                   .                                          .                                              .
> >       .                                   .                                          .                                              .
> >       .                                   .                                          .                                              .
> >
> > A format like above or anything similar to it will work. Please give an example
> >
> > Any help will be appreciated...
> >
> >
> >
> >
> >
> > Best regards
> >
> > Uzair Mannan
> > Cell: +923323489950
> > NED University of Engineering & Technology
> > Karachi, Pakistan
> >
> > _______________________________________________
> > gradsusr mailing list
> > gradsusr at gradsusr.org
> > http://gradsusr.org/mailman/listinfo/gradsusr
> 
> 
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
> 
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr

--
Jennifer M. Adams
Center for Ocean-Land-Atmosphere Studies (COLA)
111 Research Hall, Mail Stop 2B3
George Mason University
4400 University Drive
Fairfax, VA 22030 





-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20131007/9f251c63/attachment-0001.html 


More information about the gradsusr mailing list