Commit 9daf6c53 authored by Carl Schreck's avatar Carl Schreck
Browse files

Automated Nightly Commit - Thu Jun 21 00:00:26 EDT 2018

parent e5333202
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; time_range.ncl
; Carl Schreck (carl@cicsnc.org)
; November 2011
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Description: Print the time-range and optionally change the units
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
load "$CJS_NCL_LIB/lib.time.ncl"
begin
; These are some parameters that could be useful to have up top
if( .not.isvar("path") ) then
path = "*nc"
end if
if( .not.isvar("timeVar") ) then
timeVar = "time"
end if
if( .not.isvar("timeUnits") ) then
timeUnits = "days since 1800-01-01 00:00:00"
end if
print("path="+path)
print("timeVar="+timeVar)
if( isStrSubset( path, "*" ) ) then
pathList = systemfunc( "ls " + path )
else
pathList = path
end if
do pathInd = 0, dimsizes(pathList)-1
print( (pathInd+1) + ": " + pathList(pathInd) )
ioFile = addfile( pathList(pathInd), "w" )
if( isfilevar( ioFile, timeVar ) ) then
time = ioFile->$timeVar$
print( (/ " " + time@units /) )
if( typeof( time ).eq."float" ) then
time = tofloat( (/ cd_convert( time, timeUnits ) /) )
else
time = (/ cd_convert( time, timeUnits ) /)
end if
time@units = timeUnits
time!0 = timeVar
add_time_atts( time )
time&$timeVar$ = time
print( " Start: " + time@beginning_date )
print( " End: " + time@ending_date )
print( " Range: " + time@actual_range(0) )
print( " Range: " + time@actual_range(1) )
print( " Delta: " + time@delta_t )
print( " Length: " + dimsizes(time) )
print( " Units: " + time@units )
ioFile->time = time
ioFile->time@beginning_date = time@beginning_date
ioFile->time@ending_date = time@ending_date
ioFile->time@units = time@units
ioFile->time@actual_range = time@actual_range
delete(time)
delete(ioFile)
end if
end do
end
#!/bin/bash
path=$1
timeVar=$2
timeUnits=$3
NCL_SCRIPT=/home/carl/lib/ncl_tools/change_time_units.ncl
NCL_OPTION=""
if [ ! -z "$path" ];
then
NCL_OPTION="$NCL_OPTION path=\"$path\""
fi
if [ ! -z "$timeVar" ];
then
NCL_OPTION="$NCL_OPTION timeVar=\"$timeVar\""
fi
if [ ! -z "$timeUnits" ];
then
NCL_OPTION="$NCL_OPTION timeUnits=\"$timeUnits\""
fi
echo $NCL_OPTION
ncl $NCL_SCRIPT $NCL_OPTION
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment