TAHOPE_CWB_data_demonstration

The below demonstrates the elegent way to acess CWB data in TAIHOPE project through python-based tools( i.e. cwbplot module)

For more detail information, please see:https://cwbplot.readthedocs.io/en/dev/ (under construction)

[1]:
##import CWB developed module
import cwbplot.IO_tools as IO
[2]:
##import python utility module
import numpy as np
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import warnings
warnings.filterwarnings('ignore')

MSC satellite data

[3]:
#1. Given MSC data file path, no need for untar.
file_twn='DATA/MSC_SAT/2022-03-21_0900.TAIWAN_NWP.VIS.1350.tar.gz'
file_asia='DATA/MSC_SAT/2022-03-21_0900.EASTASIA_NWP.IR1.2750.tar.gz'
#2 Using MSC_READ function and get data object, the info shows data contain albedo(alb),
#   grayscale value(cnt), and brightnes temperature(btp)
taiwan_obj=IO.MSC_READ(file_twn)
asia_obj = IO.MSC_READ(file_asia)
#3 all data info are in this structured object
<TarInfo '2022-03-21_0900.TAIWAN_NWP.VIS.1350.alb' at 0x7fe9999684f8>
<TarInfo '2022-03-21_0900.TAIWAN_NWP.VIS.1350.Cnt' at 0x7fe9999685c0>
<TarInfo '2022-03-21_0900.EASTASIA_NWP.IR1.2750.btp' at 0x7fe9999685c0>
<TarInfo '2022-03-21_0900.EASTASIA_NWP.IR1.2750.Cnt' at 0x7fe9999684f8>
[4]:
## Projection for TAWINAN AREA
bm_twn = Basemap(projection='tmerc', resolution='i',lat_0=23.7,lon_0=121.0,\
            llcrnrlon=116.1417,llcrnrlat=19.0295,urcrnrlon=126.2109,urcrnrlat=28.2065)

## Projection for EASTASIA
bm_asia = Basemap(projection='lcc', resolution='i',\
            lat_1=30.,lat_2=60.,lat_0=0,lon_0=128.5,\
            llcrnrlon=102.111,llcrnrlat=-1.503,\
             urcrnrlon=155.270,urcrnrlat= 48.589)

[5]:
bm_twn.pcolormesh(taiwan_obj.lon ,taiwan_obj.lat,taiwan_obj.data['VIS_ALB'],cmap='binary_r',latlon=True)
bm_twn.drawcoastlines(color='w')
plt.colorbar()
plt.title('TAIWAN AREA ALEBDO for VIS BAND AT 0900 LST')
[5]:
Text(0.5, 1.0, 'TAIWAN AREA ALEBDO for VIS BAND AT 0900 LST')
../_images/example_TAHOPE_CWB_data_demonstration_7_1.png
[6]:
bm_asia.pcolormesh(asia_obj.lon ,asia_obj.lat,asia_obj.data['IR1_BTP'],cmap='hsv',latlon=True)
bm_asia.drawcoastlines(color='w')
bm_asia.drawparallels(np.arange(0,60,10) , labels=[1,0,0,0] , fontsize=10,color='w')
bm_asia.drawmeridians(np.arange(80,180,10),labels=[0,0,0,1],fontsize=10,color='w')
plt.colorbar()
plt.title('EASTASIA AREA Bnt for IR BAND AT 0900 LST')
[6]:
Text(0.5, 1.0, 'EASTASIA AREA Bnt for IR BAND AT 0900 LST')
../_images/example_TAHOPE_CWB_data_demonstration_8_1.png

Max combine Radar Reflectivity

[7]:
##Note that function "COMPREF_READ" can recognized both radar reflectivity and QPE data
compress_dat='DATA/RADAR/COMPREF.20220321.0000.gz'
out=IO.COMPREF_READ(compress_dat)
bm_twn.drawcoastlines()
bm_twn.contourf(out.lon,out.lat,out(),**out.cwbcolorbar(),latlon=True)
plt.colorbar()
print(out)
unzip files
CWB CREF binary format([('', '<i2')])
TIME:Mon Mar 21 00:00:00 2022
DIMX,DIMY,DIMZ=921,881,1

../_images/example_TAHOPE_CWB_data_demonstration_10_1.png

Radar QPE

[8]:
qpe_dat='DATA/qpe/CB_GC_PCP_1H_RAD.20220328.0000.gz'
out=IO.COMPREF_READ(qpe_dat)
bm_twn.drawcoastlines()
bm_twn.contourf(out.lon,out.lat,out(),**out.cwbcolorbar(),latlon=True)
plt.colorbar()
print(out)
unzip files
CWB QPE binary format([('', '<i2')])
TIME:Mon Mar 28 00:00:00 2022
DIMX,DIMY,DIMZ=441,561,1

../_images/example_TAHOPE_CWB_data_demonstration_12_1.png

Numerical model data (DMSKEY)

DMSKEY NAMING:[LEVEL]+[FIELDS]+[DOMAIN] (3-digits for each elements)

LEVEL:
  • 850 means 850 hPa,

  • B00 means ground level

FIELDS:
  • See Reference DMSKEY(1)

For more detials for combinations of LEVEL and FIELDS, see Referecne DMSKEY(2)

DOMAIN:
  • WD01: 15km resolution

  • WD02: 3-km resolution

  • WF02: 3-km but only Taiwan area

The demstration below shows the u,v wind and temperature at 850 hPa in 3km resolution domain(WD02).

[9]:
def DMSXYDIM(WXX):
    ''' function for return xdim,ydim at once
        EX: xdim,ydim=DMSXYDIM("WF02")
    '''
    if WXX=='WD01': xdim,ydim=661,385
    if WXX=='WD02': xdim,ydim=1158,673
    if WXX=='WF02': xdim,ydim=263,303
    if WXX=='WE01': xdim,ydim=450,450
    return xdim,ydim

def DMSTAIL(WXX):
    ''' function for return tail of DMSKEY in string format
    '''
    domain2grid={"WD01":"0254485" ,"WD02":"0779334" ,"WF02":"0079689","WD03":"0729136","WE01":"0202500"}
    return domain2grid[WXX]

file_path='/IFS6/data2/datarfs/c164/test/2022032100000012/'
#### 20222032100 means model initial at 2022/03/21 00 UTC
#### 0000012 means forecast time is 12 hour
dms_lat = np.fromfile(file_path+'X00LATWD02H0779334',dtype='>d',count=-1,sep="") #LAT
dms_lon = np.fromfile(file_path+'X00LONWD02H0779334',dtype='>d',count=-1,sep="") #LON
dms_u = np.fromfile(file_path+'850200WD02H0779334',dtype='>d',count=-1,sep="")
dms_v = np.fromfile(file_path+'850210WD02H0779334',dtype='>d',count=-1,sep="")
dms_rh = np.fromfile(file_path+'850510WD02H0779334',dtype='>d',count=-1,sep="")
dms_t = np.fromfile(file_path+'850100WD02H0779334',dtype='>d',count=-1,sep="")
xdim,ydim=DMSXYDIM("WD02")
data_lat= np.float32(np.reshape(dms_lat, (xdim,ydim), order='F'))
data_lon= np.float32(np.reshape(dms_lon, (xdim,ydim), order='F'))
data_u= np.float32(np.reshape(dms_u, (xdim,ydim), order='F'))
data_v= np.float32(np.reshape(dms_v, (xdim,ydim), order='F'))
data_rh= np.float32(np.reshape(dms_rh, (xdim,ydim), order='F'))
data_t= np.float32(np.reshape(dms_t, (xdim,ydim), order='F'))
[10]:
bm = Basemap(projection='tmerc',resolution='i', fix_aspect=True, llcrnrlon=110,
             llcrnrlat=15, urcrnrlon=130,urcrnrlat=32,lat_0=45,lon_0=120)
bm.drawcoastlines()
bm.contourf(data_lon,data_lat,data_t,latlon=True)
bm.quiver(data_lon[::10,::10],data_lat[::10,::10],data_u[::10,::10],data_v[::10,::10]
          ,scale=500,latlon=True)
plt.colorbar()
plt.title('Numerical Model result of 12 hr forecast from 2022/3/21 00 UTC \n Temp vs. UV-wind at 850hPa')
[10]:
Text(0.5, 1.0, 'Numerical Model result of 12 hr forecast from 2022/3/21 00 UTC \n Temp vs. UV-wind at 850hPa')
../_images/example_TAHOPE_CWB_data_demonstration_16_1.png

Reference DMSKEY

  1. 3D fields at mandatory levels

    1. ‘000’ : geopotential height (hPa)

    2. ‘100’ : temperature (K)

    3. ‘150’ : Dew Point temperature (K)

    4. ‘200’ : u (m/s)

    5. ‘210’ : v (m/s)

    6. ‘220’ : omega (hPa/hr)

    7. ‘510’ : RH (%)

    8. ‘500’ : q (kg/kg) specifc humidity

    9. ‘550’ : ql (kg/kg) (=qc+qrain )liquid water mixing ratio

    10. ‘552’ : qice (kg/kg) ice mixing ratio

    11. ‘553’ : qrain (kg/kg) rain water mixing ratio

    12. ‘554’ : qsnow (kg/kg) snow mixing ratio

    13. ‘555’ : qgraup (kg/kg) graupel mixing ratio

    14. ‘556’ : qv (kg/kg) water vapor mixing ratio

    15. ‘551’ : qc (kg/kg) cloud water mixing ratio

  2. 2D fields

    1. ‘B00010’ : Terrain surface pressure (hPa)

    2. ‘B00100’ : Temperature at model’s lowest sigma level

    3. ‘B00150’ : Dew Point Temperature at model’s lowest sigma level

    4. ‘B00200’ : u at model’s lowest sigma level

    5. ‘B00210’ : v at model’s lowest sigma level

    6. ‘B00510’ : RH at model’s lowest sigma level

    7. ‘B0062T’ : Total Precipitation (=’B0063T’+’B0064T’)

    8. ‘B00620’ : Dmskey defied Precipitation (note: MUST have B0062T as well,and Recommanded to extract all tau to avoid calculated error, otherwise you need to put SPECIFIC TAUs for calculating this key!)

    9. ‘B0063T’ : Total Precipitation caused by cumulus parameterization

    10. ‘B00630’ : Precipitation caused by cumulus parameterization (note: MUST have B0063T to calculate this key)

    11. ‘B0064T’ : Total Precipitation caused by microphysic parameterization

    12. ‘B00640’ : Precipitation caused by microphysic parameterization (note: MUST have B0064T to calculate this key)

    13. ‘B02100’ : Temperature at 2m Height

    14. ‘B02150’ : Dew Point Temperature at 2m height

    15. ‘B02510’ : RH at 2m height

    16. ‘B10200’ : u at 10m height

    17. ‘B10210’ : v at 10m height

    18. ‘SSL010’ : Sea level pressure (hPa)

    19. ‘S00060’ : Terrain Height

    20. ‘S00070’ : Land Sea Mask (Land:1, Sea:0)

    21. ‘S000LU’ : Land Use Type (USGS 24 categories)

    22. ‘S00100’ : Surface Skin Temperature

    23. ‘W00100’ : Sea Surface Temperature (SST)

    24. ‘X00LAT’ : Latitude

    1. ‘X00MOS’ : Column vector of the radar reflectivity

    2. ‘S004F0’ : PBL height

    3. ‘B80200’ : U-wind at 80-m above ground level

    4. ‘B80210’ : V-wind at 80-m above ground level

    5. ‘S00420’ : Sensible heat flux

    6. ‘S00430’ : Latent heat flux

    7. ‘X00340’ : OLR

    8. ‘S00320’ : LongWave radiation flux at surface

    9. ‘S00310’ : ShortWave radiation flux at surface

    10. ‘X00VEN’ : Ventilation index

    11. ‘X00PWV’ : Precipitable water vapor

    12. ‘X00CAP’ : CAPE for the parcel with max theta-e in the column

    13. ‘X00CIN’ : CIN for the parcel with max theta-e in the column

    14. ‘B02500’ : Specific humidity at 2-m height

    15. ‘S005C0’ : Canopy water

    16. ‘S00431’ : UPWARD MOISTURE FLUX AT THE SURFACE

    17. ‘B00REF’ : Radar reflectivity at lowest eta level

    18. ‘S004A0’ : U* IN SIMILARITY THEORY

    19. ‘S00440’ : GROUND HEAT FLUX

    20. ‘B02556’ : mixing ratio at 2-m height

    21. ‘B00PFC’ : Surface pressure calculated by using altimeter equation

    22. ‘B00623’ : 6hr precipitation