Actions

Difference between revisions of "Csu radartools tutorial"

From Lrose Wiki

Line 22: Line 22:
 
----
 
----
  
The Example file is from the C-band polarimetric SEA-POL radar. The raw data are in sigmet native format:<br/>
+
The Example file is from the C-band polarimetric SEA-POL radar. The raw data are in sigmet native format.<br/>
 
 
SEA20190917_073004
 
 
<br/>
 
<br/>
*First convert the data to cfradial data to be more easily transferable to other programs.<br/>
+
=== Python Imports ===
We can do this from a command line, but we can also do it from python with the os command.<br/>
+
<code lang="python">
 +
import numpy as np
 +
from copy import deepcopy
 +
import os
 +
import pyart
 +
from CSU_RadarTools.csu_radartools import csu_kdp
 +
from CSU_RadarTools.csu_radartools import csu_misc</code>
 
<br/>
 
<br/>
<code>
+
=== Convert to CFRADIAL ===
mydir = '/Users/bdolan/scratch/LROSE/SEA-POL/ppi/'<br/>
+
Convert the data to cfradial data to be more easily transferable to other programs.<br/>
os.system(f'RadxConvert -f {mydir}SEA20190917_071005 -outdir {mydir}cfrad')</code></br>
+
We can do this using RadxConvert from a command line, but we can also do it from python with the os command.<br/>
 +
<br/>
 +
<code lang="python">
 +
  mydir = '/Users/bdolan/scratch/LROSE/SEA-POL/ppi/'<br/>
 +
  os.system(f'RadxConvert -f {mydir}SEA20190917_071005 -outdir {mydir}cfrad')</code></br>
 
<br/>
 
<br/>
 
This will put the output in a directory for the date in directory 'cfrad'.<br/>
 
This will put the output in a directory for the date in directory 'cfrad'.<br/>
<br/>
 
 
Now we have a file called:<br/>
 
Now we have a file called:<br/>
 
cfrad.20190917_071006.545_to_20190917_071353.149_SEAPOL_SUR.nc<br/>
 
cfrad.20190917_071006.545_to_20190917_071353.149_SEAPOL_SUR.nc<br/>
 
<br/>
 
<br/>
 
There are a lot of variables in this file, but the ones of interest are:
 
There are a lot of variables in this file, but the ones of interest are:
DBZ: Reflectivity
+
DBZ: Reflectivity<br/>
ZDR: Differential Reflectivity’
+
ZDR: Differential Reflectivity<br/>
UNKNOWN_ID_82: Correlation Coefficient
+
UNKNOWN_ID_82: Correlation Coefficient<br/>
VEL: Radial velocity
+
VEL: Radial velocity<br/>
SQI: Signal Quality Index
+
SQI: Signal Quality Index<br/>
PHIDP: Differential phase
+
PHIDP: Differential phase<br/>
SNR: Signal to noise ratio
+
SNR: Signal to noise ratio<br/>
 
</br>
 
</br>
*Next do some quality control using PyART and CSU_Radartools.</br>
+
=== QC with CSU_Radartools and PyART ===
 +
Do some quality control using PyART and CSU_Radartools.</br>
 +
<br/>
 +
====Special handling for SEA-POL====
 +
These are PECULIARS TO THE SEA-POL DATA. YMMV</br>
 +
*Blanked sector over the wheelhouse:
 +
We will look for large blocks of azimuthal jumps to mask them. Get the difference between each azimuth and look for jumps larger than 30º. If so, mask the data so it plots correctly.</br>
 +
<code lang="python"><br/>
 +
az_diff = np.diff(radar.azimuth['data'])
 +
jumps = np.where(np.abs(az_diff) >= 30.0)[0]
 +
if len(jumps):
 +
  for f in radar.fields.keys():
 +
      for j in jumps:
 +
        radar.fields[f]['data'][j].mask = True
 +
        radar.fields[f]['data'][j+1].mask = True
 
<br/>
 
<br/>
<code lang="python" line>
 
import numpy as np</br>
 
from copy import deepcopy</br>
 
import os</br>
 
import pyart</br>
 
from CSU_RadarTools.csu_radartools import csu_kdp</br>
 
from CSU_RadarTools.csu_radartools import csu_misc</br>
 
 
</code>
 
</code>
<br/>
+
*The correlation coefficient is incorrect, but we can calculate it from UNKNONW_ID_82 field.<br/>
Special handling for SEA-POL:</br>
+
Now correct the UNKNOWN_ID_82 field to transform into the correlation coefficient (Again, this is only needed for this data).<br/>
Blanked sector over the wheelhouse: we will look for large blocks of azimuthal jumps to mask them.</br>
+
<code lang="python">
For some reason the correlation coefficient was not correct but can be calculated from the UNKNOWN field</br>
+
ccorr = deepcopy(radar.fields['UNKNOWN_ID_82']['data'])
###These are PECULIARS TO THE SEA-POL DATA. YMMV</br>
+
ccorr[ccorr<0] += 65535
#Get the difference between each azimuth and look for jumps larger than 30º. If so, mask the data so it plots correctly.</br>
+
ccorr = (ccorr-1)/65533.0
<code lang="python" line>
+
radar.add_field_like('RHOHV','CC',ccorr)
  az_diff = np.diff(radar.azimuth['data'])
 
  jumps = np.where(np.abs(az_diff) >= 30.0)[0]
 
  if len(jumps):</br>
 
      for f in radar.fields.keys():
 
          for j in jumps:
 
            radar.fields[f]['data'][j].mask = True
 
            radar.fields[f]['data'][j+1].mask = True
 
#Now correct the Untitled field to transform into the correlation coefficient.</br>
 
ccorr = deepcopy(radar.fields['UNKNOWN_ID_82']['data'])</br>
 
ccorr[ccorr<0] += 65535</br>
 
ccorr = (ccorr-1)/65533.0</br>
 
radar.add_field_like('RHOHV','CC',ccorr)</br>
 
 
</code>
 
</code>

Revision as of 19:37, 18 August 2021

Overview


This tutorial will walk through the steps to read and convert a raw radar file, quality control the data (removing unwanted artifacts and echoes, unfold radial velocity and calculate Kdp), then grid the data, and finally process the gridded data to end up with hydrometeor identification, precipitation rates, and DSD information. This is generally focused on surface polarimetric X, C, or S-band radar. We will apply a series of corrections

  • Unfold radial velocity
  • Calculate Kdp
  • Apply thresholds to remove non-meteorological data
  • Calculate the attenuation and differential attenuation
  • Despeckle and remove 2nd trip

Modules available from GitHub


Scientific Background



Step-by-step Instructions


The Example file is from the C-band polarimetric SEA-POL radar. The raw data are in sigmet native format.

Python Imports

import numpy as np
from copy import deepcopy
import os
import pyart
from CSU_RadarTools.csu_radartools import csu_kdp
from CSU_RadarTools.csu_radartools import csu_misc


Convert to CFRADIAL

Convert the data to cfradial data to be more easily transferable to other programs.
We can do this using RadxConvert from a command line, but we can also do it from python with the os command.

 mydir = '/Users/bdolan/scratch/LROSE/SEA-POL/ppi/'
os.system(f'RadxConvert -f {mydir}SEA20190917_071005 -outdir {mydir}cfrad')


This will put the output in a directory for the date in directory 'cfrad'.
Now we have a file called:
cfrad.20190917_071006.545_to_20190917_071353.149_SEAPOL_SUR.nc

There are a lot of variables in this file, but the ones of interest are: DBZ: Reflectivity
ZDR: Differential Reflectivity
UNKNOWN_ID_82: Correlation Coefficient
VEL: Radial velocity
SQI: Signal Quality Index
PHIDP: Differential phase
SNR: Signal to noise ratio

QC with CSU_Radartools and PyART

Do some quality control using PyART and CSU_Radartools.

Special handling for SEA-POL

These are PECULIARS TO THE SEA-POL DATA. YMMV

  • Blanked sector over the wheelhouse:

We will look for large blocks of azimuthal jumps to mask them. Get the difference between each azimuth and look for jumps larger than 30º. If so, mask the data so it plots correctly.

az_diff = np.diff(radar.azimuth['data'])
jumps = np.where(np.abs(az_diff) >= 30.0)[0]
if len(jumps):
  for f in radar.fields.keys():
     for j in jumps:
        radar.fields[f]['data'][j].mask = True
        radar.fields[f]['data'][j+1].mask = True


  • The correlation coefficient is incorrect, but we can calculate it from UNKNONW_ID_82 field.

Now correct the UNKNOWN_ID_82 field to transform into the correlation coefficient (Again, this is only needed for this data).

ccorr = deepcopy(radar.fields['UNKNOWN_ID_82']['data'])
ccorr[ccorr<0] += 65535
ccorr = (ccorr-1)/65533.0
radar.add_field_like('RHOHV','CC',ccorr)