Commit dbbfd214 authored by Carl Schreck's avatar Carl Schreck

Automated Nightly Commit - Thu Jan 31 00:00:24 EST 2019

parent 1513408a
......@@ -21,11 +21,13 @@ begin
print_clock( "Here we go!" )
; These are some parameters that could be useful to have up top
path = "~/data/ibtracs/hotel1/IBTrACS.ALL.hotel1.nc"
; path = "~/data/ibtracs/hotel1/IBTrACS.ALL.hotel1.nc"
; path = "~/data/ibtracs/hotel1/IBTrACS.last3years.hotel1.nc"
path = "~/data/state_of_climate/tcvitals.nc"
; path = "/home/carl/data/ibtracs/v03r09/wmo.1min.nc"
; path = "/home/carl/data/ibtracs/v03r05/Allstorms.ibtracs_wmo.v03r05.nc"
; timeVar = "source_time"
timeVar = "time"
timeVar = "wmo_time"
; timeVar = "time"
print_clock("Reading")
ioFile = addfile(path,"w")
......
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; tcvitals_to_netcdf.ncl
; Carl Schreck (cjschrec@ncsu.edu)
; May 2014
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Description: Read NCEP's tcvitals file and output it to an IBTrACS-style
; netCDF
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
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"
;load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
;load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/diagnostics_cam.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/cd_string.ncl"
load "$CJS_NCL_LIB/print_clock.ncl"
load "$CJS_NCL_LIB/lib.array.ncl"
begin ; main
print_clock( "Here we go!" )
; These are some parameters that could be useful to have up top
fileName = "tcvitals"
basePath = "/home/carl/data/monitor/v2/tcvitals/"
inPath = basePath + fileName + ".txt"
outPath = basePath + fileName + "4.nc"
maxFix = 200
maxStorm = 1000
inString = asciiread( inPath, -1, "string" )
fixOrg = str_get_field( inString, 1, " " )
fixId = str_get_field( inString, 2, " " )
fixName = str_get_field( inString, 3, " " )
fixYear = toint( str_get_cols( inString, 19, 22 ) )
fixMonth = toint( str_get_cols( inString, 23, 24 ) )
fixDay = toint( str_get_cols( inString, 25, 26 ) )
fixHour = toint( str_get_cols( inString, 28, 29 ) )
inLat = toint( str_get_cols( inString, 33, 35 ) )
latHem = str_get_cols( inString, 36, 36 )
inLon = toint( str_get_cols( inString, 38, 41 ) )
lonHem = str_get_cols( inString, 42, 42 )
fixPres = toint( str_get_cols( inString, 52, 55 ) )
fixWind = toint( str_get_cols( inString, 66, 68 ) )
timeUnits = "days since 1800-01-01 00:00:00"
zeros = fixYear * 0
fixTime = cd_inv_calendar( fixYear, fixMonth, fixDay, fixHour, zeros, zeros, \
timeUnits, 0 )
fixLat = inLat * 0.1
fixLat = where( latHem.eq."N", fixLat, -fixLat )
fixLon = inLon * 0.1
fixLon = where( lonHem.eq."E", fixLon, -fixLon )
; convert from m/s to kt
fixWind = 5 * round( tofloat(fixWind) / 2.5722, 3 )
; print( fixOrg + " " + fixId + " " + fixName + " " + cd_string( fixTime, "" ) \
; + " " + fixLat + " " + fixLon + " " + fixPres + " " + fixWind )
outId = new( maxStorm, string )
outOrg = new( maxStorm, string )
outName = new( maxStorm, string )
outNfix = new( maxStorm, integer )
outTime = new( (/ maxStorm, maxFix /), double )
outLat = new( (/ maxStorm, maxFix /), float )
outLon = new( (/ maxStorm, maxFix /), float )
outWind = new( (/ maxStorm, maxFix /), float )
outPres = new( (/ maxStorm, maxFix /), float )
fixCounter = 0
stormCounter = 0
do while( fixCounter.lt.dimsizes(fixLat) )
hasSameId = fixId.eq.fixId(fixCounter)
isWithin100Days = abs( fixTime - fixTime(fixCounter) ).le.100
stormInd := ind( hasSameId.and.isWithin100Days )
nFix = dimsizes(stormInd)
if( nFix.gt.1 ) then
deltaInd := stormInd(1:) - stormInd(0:nFix-2)
if( any( deltaInd.ne.1 ) ) then
print( "WARNING: " + fixCounter + " " + fixId(fixCounter) \
+ " " + fixYear(fixCounter) )
print(stormInd)
end if
end if
outId(stormCounter) = fixYear( stormInd(0) ) + "-" + fixId( stormInd(0) )
outOrg(stormCounter) = fixOrg( stormInd(0) )
outName(stormCounter) = fixName( stormInd(nFix-1) )
outNfix(stormCounter) = nFix
outTime(stormCounter,:nFix-1) = fixTime(stormInd)
outLat (stormCounter,:nFix-1) = fixLat (stormInd)
outLon (stormCounter,:nFix-1) = fixLon (stormInd)
outWind(stormCounter,:nFix-1) = fixWind(stormInd)
outPres(stormCounter,:nFix-1) = fixPres(stormInd)
stormCounter = stormCounter + 1
fixCounter = fixCounter + nFix
end do
nStorm = stormCounter - 1
print_clock( "Finding yyyymm" )
yyyymm = new( dimsizes(outTime), integer )
copy_VarCoords( outTime, yyyymm )
do s = 0,nStorm-1
do t = 0,maxFix-1
if( ismissing(outTime(s,t)) ) then
yyyymm(s,t) = yyyymm@_FillValue
else
yyyymm(s,t) = cd_calendar( outTime(s,t), -1 )
end if
end do
end do
print_clock( "Finding basins" )
natlX = (/ 290, 290, 278, 274, 260, 260, 360, 360, 293 /)
natlY = (/ 0, 8.5, 8.5, 13, 20, 90, 90, 0, 0 /)
epacX = (/ 290, 290, 278, 274, 260, 260, 180, 180, 290 /)
epacY = (/ 0, 8.5, 8.5, 13, 20, 90, 90, 0, 0 /)
wpacX = (/ 180, 180, 100, 100, 180 /)
wpacY = (/ 0, 90, 90, 0, 0 /)
nioX = (/ 100, 100, 000, 000, 100 /)
nioY = (/ 0, 90, 90, 0, 0 /)
sioX = (/ 135, 135, 000, 000, 135 /)
sioY = (/ 0, -90, -90, 0, 0 /)
spacX = (/ 135, 135, 360, 360, 135 /)
spacY = (/ 0, -90, -90, 0, 0 /)
basin = new( dimsizes(outLat), string )
lon360 = where( outLon.lt.0, outLon+360, outLon )
basin = where( point_in_poly( lon360, outLat, natlX, natlY ), "NA", basin )
basin = where( point_in_poly( lon360, outLat, wpacX, wpacY ), "WP", basin )
basin = where( point_in_poly( lon360, outLat, epacX, epacY ), "EP", basin )
basin = where( point_in_poly( lon360, outLat, spacX, spacY ), "SP", basin )
basin = where( point_in_poly( lon360, outLat, nioX, nioY ), "NI", basin )
basin = where( point_in_poly( lon360, outLat, sioX, sioY ), "SI", basin )
genesis_basin = basin(:,0)
print( genesis_basin + " " + outName )
print_clock( "Writing" )
system( "rm " + outPath )
outFile = addfile( outPath, "c" )
char_outName = tochar( outName(:nStorm) )
char_outName!0 = "nStorm"
char_outName!1 = "nCharName"
char_outName@long_name = "Storm Name"
outFile->name = char_outName
char_outId = tochar( outId(:nStorm) )
char_outId!0 = "nStorm"
char_outId!1 = "nCharId"
char_outId@long_name = "Storm ID"
outFile->sid = char_outId
char_outOrg = tochar( outOrg(:nStorm) )
char_outOrg!0 = "nStorm"
char_outOrg!1 = "nCharOrg"
char_outOrg@long_name = "NHC or JTWC"
outFile->source = char_outOrg
outNfix!0 = "nStorm"
outNfix@long_name = "Fixes per storm"
outFile->nFix = outNfix(:nStorm)
outTime!0 = "nStorm"
outTime!1 = "nTime"
outTime@long_name = "Time"
outFile->time = outTime(:nStorm,:)
outLat!0 = "nStorm"
outLat!1 = "nTime"
outLat@long_name = "Latitude"
outLat@units = "degrees_north"
outFile->usa_lat = outLat(:nStorm,:)
outLon!0 = "nStorm"
outLon!1 = "nTime"
outLon@long_name = "Longitude"
outLon@units = "degrees_east"
outFile->usa_lon = outLon(:nStorm,:)
outWind!0 = "nStorm"
outWind!1 = "nTime"
outWind@long_name = "Maximum Sustained Wind (MSW)"
outWind@units = "kt"
outFile->usa_wind = outWind(:nStorm,:)
outPres!0 = "nStorm"
outPres!1 = "nTime"
outPres@long_name = "Minimum Central Pressure (MCP)"
outPres@units = "mb"
outFile->usa_pres = outPres(:nStorm,:)
char_outBasin = tochar( basin(:nStorm,:) )
char_outBasin!0 = "nStorm"
char_outBasin!1 = "nTime"
char_outBasin!2 = "nCharBasin"
char_outBasin@long_name = "Basin"
char_outBasin@units = ""
outFile->basin = char_outBasin
char_genBasin = tochar( genesis_basin(:nStorm) )
char_genBasin!0 = "nStorm"
char_genBasin!1 = "nCharGenBasin"
char_genBasin@long_name = "Basin of genesis"
char_genBasin@units = ""
outFile->genesis_basin = char_genBasin
yyyymm!0 = "nStorm"
yyyymm!1 = "nTime"
yyyymm@long_name = "YYYYMM"
outFile->yyyymm = yyyymm(:nStorm,:)
nature = new( dimsizes(yyyymm), string )
nature = "TS"
char_nature = tochar( nature(:nStorm,:) )
char_nature!0 = "nStorm"
char_nature!1 = "nTime"
char_nature!2 = "nCharNature"
char_nature@long_name = "Storm nature"
outFile->nature = char_nature
track_type = new( dimsizes(genesis_basin), string )
track_type = "main"
char_type = tochar( track_type(:nStorm) )
char_type!0 = "nStorm"
char_type!1 = "nCharType"
char_type@long_name = "Track type"
outFile->track_type = char_type
print_clock( "Thank you, come again." )
end; main
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