Re: cutting a string

From: Jatin Kala <jatin.kala.jk_at_nyahnyahspammersnyahnyah>
Date: Mon Oct 14 2013 - 15:34:00 MDT

In many cases, the model name and start and end dates are a "global file attribute" of the netcdf file you are opening and easily accessible. Can you use ncdump -h to check attributes. May be worth checking this first.
Another way to think about this is to start from the end of the string and going backwards, as the path may change. E.g., ".nc" will always be the last 3 characters of the string, irrespective of the total number of characters in the string, so you avoid hard-coding too much. Converting from string to char and using the size for of the char array can help to make things more generic.

Cheers,
Jatin.

On 15/10/2013, at 5:16 AM, Mahesh Varma wrote:

> Hello,
> I was just wondering if there is a way in NCL to cut a string. I have a string which is something like "/Volumes/HD2/CMIP5/Ext/combined_files/ts/ts_Amon_ACCESS1-0_historical-rcp45_r1i1p1_185001-210012.nc". I would like to extract the model name (in this case it is "ACCESS1-0") and the starting and ending date ( in this case starting date is 185001 and ending date is 210012) from this string. I tried using the cut command with systemfunc but was not successful. Any help will be appreciated.
> Thanks,
> Mahesh
> _______________________________________________
> 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 Mon Oct 14 15:34:11 2013

This archive was generated by hypermail 2.1.8 : Tue Oct 22 2013 - 10:35:27 MDT