Re: How to change name.

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed Aug 24 2011 - 15:17:05 MDT

DaveA ... THX for answering. D

On 8/24/11 3:08 PM, Dave Allured wrote:
> Erick,
>
> Are you trying to make one output file for each input file? Or
> something more complicated?
>
> You have "time" as an array of 24 times. Just change this to a
> single time, and the next line will make "newfile" into a single
> file name.
>
> time = "0000"
>
> If you have multiple input files for different times, you should add
> a do loop, and process them one file at a time.
>
> nfiles = dimsizes (files)
> do fi = 0, nfiles-1
> current_file = files(fi)
> ; addfile for input; make output file name; addfile for output
> end
>
> If you need more advice, please show us an example of the COMPLETE
> path and file name that you want, for both input and output files.
> I can't figure out this part from your original message.
>
> --Dave
>
> On 8/24/2011 1:43 PM, Erick Rivera Lemus wrote:
>> Hello,
>>
>> I am trying to work out how to change my file name. In this example I
>> ingest hourly ASCII files and then I convert those ASCII files into
>> NETCDF. This is an exert of the code. I am not adding the conversion
>> from ASCII to NETCDF of the code, because I know for sure it works. I
>> am only having trouble in the ouput file name. Does anybody know how
>> to ouput and change the folder name and the filename differ from the
>> input folder name? If, so do you know how to change the day and month
>> automatically? If so do you know how to change it so that it would
>> output it with that name.
>>
>> Basically what I am shooting at is to have an automated cron that
>> grabs the recent ascii file and converts it into netcdf file. I know
>> how to do it by specifying the name, but would like to do it
>> automatically. Anybody has any suggestions?
>>
>>
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl";
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl";
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl";
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl";
>>
>> 1) HERE IS HOW I INGEST MY ASCII FILES....
>>
>> ; Set path equal to the location of the files
>> pat="/Volumes/lemus/CODAR/totals_13mHz/totals/ascii/OI_BPU_2011_06_28";
>> files = systemfunc("ls " + pat + "* 2>/dev/null | grep '[0-9]$'");
>> print(files);
>>
>> ; exit
>>
>> if (any(ismissing(files))) then
>> print("No files found!");
>> exit;
>> end if
>>
>> 2) THIS IS MY OUTPUT FOLDER/FILE NAME
>>
>> ; Open the output .nc file
>> outdir = "/Volumes/lemus/CODAR/totals_13mHz/totals/netcdf/";
>> fname = "OI_BPU_2011_06_28_";
>> time = (/
>> 0000,0100,0200,0300,0400,0500,0600,0700,0800,0900,1000,1100,1200,1300,1400,1500,1600,1700,1800,1900,2000,2100,2200,2300
>> /);
>> newfile = (outdir + fname + time);
>> print (newfile);
>> nc = addfile(newfile + ".nc", "c");
>>
>> ; Add the variables
>> nc->lat = latitudes;
>> nc->lon = longitudes;
>> nc->u = U;
>> nc->v = V;
>> nc->verr = VERR;
>> nc->uerr = UERR;
>>
>>
>>
>>
>>
>> Cheers,
>> Erick Rafael Rivera Lemus
>> Software Technician
>> Institute of Marine and Coastal Sciences
>> Coastal Ocean Observation Laboratory
>>
>> Rutgers, The State University of New Jersey
>> 71 Dudley Road New Brunswick, NJ 08901
>>
>> Office: 848-932-3261
>> Fax: 732-932-8578
>> Cell: 617-447-5106
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Aug 24 15:17:11 2011

This archive was generated by hypermail 2.1.8 : Thu Aug 25 2011 - 09:54:48 MDT