How to change name.

From: Erick Rivera Lemus <lemus_at_nyahnyahspammersnyahnyah>
Date: Wed Aug 24 2011 - 13:43:56 MDT

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
Received on Wed Aug 24 13:44:04 2011

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