Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Random Forest Cloud Phase Classification Using Vertically Pointing Radar and Lidar

This notebook applies a Random Forest classifier to vertically pointing radar and lidar observations from the NSA site (during the ACME-V Campaign in 2015) to classify cloud phase into categories such as liquid, mixed phase, and ice.

The workflow assumes that two datasets are available:

  1. A vertically pointing lidar dataset

  2. A vertically pointing radar dataset

Each dataset contains measurements on a time-height grid. Because both instruments sample many vertical levels at each time, the basic machine-learning sample is not a single time step, but a single time-height gate.

In other words:

one sample = one time-height grid cell
Radar dataset:
<xarray.Dataset> Size: 14MB
Dimensions:                     (height: 596, time: 2880)
Coordinates:
  * height                      (height) float32 2kB 160.0 190.0 ... 1.801e+04
  * time                        (time) datetime64[ns] 23kB 2015-06-10 ... 201...
Data variables:
    reflectivity_best_estimate  (time, height) float64 14MB ...

Ceilometer dataset:
<xarray.Dataset> Size: 6MB
Dimensions:      (time: 2880, height: 252)
Coordinates:
  * height       (height) float32 1kB 15.0 45.0 75.0 ... 7.515e+03 7.545e+03
  * time         (time) datetime64[ns] 23kB 2015-06-10 ... 2015-06-10T23:59:30
Data variables:
    backscatter  (time, height) float64 6MB ...
Attributes:
    description:  Backscatter from ceilometer

Label dataset:
<xarray.Dataset> Size: 7MB
Dimensions:            (height: 596, time: 2880)
Coordinates:
  * height             (height) float32 2kB 0.16 0.19 0.22 ... 17.95 17.98 18.01
  * time               (time) datetime64[ns] 23kB 2015-06-10 ... 2015-06-10T2...
Data variables:
    cloud_phase_mplgr  (time, height) float32 7MB ...

spec width dataset:
<xarray.Dataset> Size: 14MB
Dimensions:         (height: 596, time: 2880)
Coordinates:
  * height          (height) float32 2kB 160.0 190.0 ... 1.798e+04 1.801e+04
  * time            (time) datetime64[ns] 23kB 2015-06-10 ... 2015-06-10T23:5...
Data variables:
    spectral_width  (time, height) float64 14MB ...
['reflectivity_best_estimate']
IOPub data rate exceeded.
The Jupyter server will temporarily stop sending output
to the client in order to avoid crashing it.
To change this limit, set the config variable
`--ServerApp.iopub_data_rate_limit`.

Current values:
ServerApp.iopub_data_rate_limit=1000000.0 (bytes/sec)
ServerApp.rate_limit_window=3.0 (secs)

Radar variable exists: True
Ceilometer variable exists: True
Label variable exists: True
Velocity variable exists: True
Spectrum width variable exists: True
MWR LWP variable exists: True
Radar shape: (2880, 596)
Ceilometer on radar grid shape: (2880, 596)
Velocity on radar grid shape: (2880, 596)
Spectrum width on radar grid shape: (2880, 596)
MWR LWP on radar time shape: (2880,)
Label shape: (2880, 596)
<xarray.DataArray 'cloud_phase_mplgr' (time: 2880, height: 596)> Size: 7MB
array([[0., 0., 0., ..., 0., 0., 0.],
       [0., 0., 0., ..., 0., 0., 0.],
       [0., 0., 0., ..., 0., 0., 0.],
       ...,
       [0., 2., 3., ..., 0., 0., 0.],
       [0., 3., 3., ..., 0., 0., 0.],
       [0., 3., 3., ..., 0., 0., 0.]], dtype=float32)
Coordinates:
  * time     (time) datetime64[ns] 23kB 2015-06-10 ... 2015-06-10T23:59:30
  * height   (height) float32 2kB 160.0 190.0 220.0 ... 1.798e+04 1.801e+04
<xarray.Dataset> Size: 62MB
Dimensions:            (height: 596, time: 2880)
Coordinates:
  * height             (height) float32 2kB 160.0 190.0 ... 1.798e+04 1.801e+04
  * time               (time) datetime64[ns] 23kB 2015-06-10 ... 2015-06-10T2...
Data variables:
    reflectivity       (time, height) float64 14MB ...
    backscatter        (time, height) float64 14MB nan nan nan ... nan nan nan
    cloud_phase_mplgr  (time, height) float32 7MB 0.0 0.0 0.0 ... 0.0 0.0 0.0
    velocity           (time, height) float64 14MB nan nan nan ... nan nan nan
    spectral_width     (time, height) float64 14MB nan nan nan ... nan nan nan
    liq                (time) float32 12kB 0.001729 0.002157 ... 0.0084 0.00925
DataFrame shape: (1716480, 8)
Loading...
                 time  height           profile_id   date_id
0 2015-06-10 00:00:00   160.0  2015-06-10 00:00:00  20150610
1 2015-06-10 00:00:30   160.0  2015-06-10 00:00:30  20150610
2 2015-06-10 00:01:00   160.0  2015-06-10 00:01:00  20150610
3 2015-06-10 00:01:30   160.0  2015-06-10 00:01:30  20150610
4 2015-06-10 00:02:00   160.0  2015-06-10 00:02:00  20150610
Number of profiles: 2880
0          0.0
1          0.0
2          0.0
3          0.0
4          0.0
          ... 
1716475    0.0
1716476    0.0
1716477    0.0
1716478    0.0
1716479    0.0
Name: cloud_phase_mplgr, Length: 1716480, dtype: float32
Phase counts in df_all before dropna:
cloud_phase_mplgr
0.0    1206915
1.0      74834
2.0     383618
3.0      19198
4.0        235
NaN      31680
Name: count, dtype: int64

Rows with phase 3 before dropna:
19198
Dataset shape: (1716480, 8)

Missing values:
height                     0
time                       0
reflectivity         1231349
backscatter          1506235
cloud_phase_mplgr      31680
velocity             1231349
spectral_width       1231349
liq                        0
dtype: int64

Phase label counts:
cloud_phase_mplgr
0.0    1206915
2.0     383618
1.0      74834
NaN      31680
3.0      19198
4.0        235
Name: count, dtype: int64

Reflectivity summary:
count    485131.000000
mean        -12.547155
std          15.823361
min         -59.022789
25%         -24.835587
50%         -13.545955
75%          -1.201333
max          31.805882
Name: reflectivity, dtype: float64

Backscatter summary:
count    210245.000000
mean          1.805199
std           0.623372
min          -1.477121
25%           1.442172
50%           1.876093
75%           2.243398
max           3.614864
Name: backscatter, dtype: float64
Model dataset shape: (141917, 8)

Phase counts after cleaning:
cloud_phase_mplgr
0      3278
1     31422
2    101036
3      6000
4       181
Name: count, dtype: int64

Missing values after cleaning:
reflectivity         0
backscatter          0
velocity             0
spectral_width       0
liq                  0
height               0
cloud_phase_mplgr    0
dtype: int64

Feature columns:
['reflectivity', 'backscatter', 'velocity', 'spectral_width', 'liq', 'height']

Unique phase labels:
[0 1 2 3 4]
Training samples: 113008
Testing samples: 28909

Number of unique training profiles:
2303

Number of unique testing profiles:
576

Training phase counts:
cloud_phase_mplgr
0     2602
1    24847
2    80633
3     4793
4      133
Name: count, dtype: int64

Testing phase counts:
cloud_phase_mplgr
0      676
1     6575
2    20403
3     1207
4       48
Name: count, dtype: int64
Random Forest training complete.
Class names:
[0, 1, 2, 3, 4]

Classification report:
              precision    recall  f1-score   support

           0       0.90      0.88      0.89       676
           1       0.96      0.98      0.97      6575
           2       0.99      0.96      0.97     20403
           3       0.64      0.90      0.75      1207
           4       0.71      0.46      0.56        48

    accuracy                           0.96     28909
   macro avg       0.84      0.84      0.83     28909
weighted avg       0.97      0.96      0.96     28909

Loading...
Saved outputs to: random_forest_phase_output_highres
<Figure size 600x500 with 2 Axes>
<Figure size 600x500 with 2 Axes>
(1716480, 8)
Loading...
                 time  height           profile_id
0 2015-06-10 00:00:00   160.0  2015-06-10 00:00:00
1 2015-06-10 00:00:30   160.0  2015-06-10 00:00:30
2 2015-06-10 00:01:00   160.0  2015-06-10 00:01:00
3 2015-06-10 00:01:30   160.0  2015-06-10 00:01:30
4 2015-06-10 00:02:00   160.0  2015-06-10 00:02:00
Number of profiles: 2880
<Figure size 800x500 with 1 Axes>
<Figure size 1200x500 with 2 Axes>
<Figure size 1200x500 with 2 Axes>
Validation classification report:
              precision    recall  f1-score   support

       Clear       0.90      0.88      0.89       676
      Liquid       0.96      0.98      0.97      6575
         Ice       0.99      0.96      0.97     20403
       Mixed       0.64      0.90      0.75      1207
     Unknown       0.71      0.46      0.56        48

    accuracy                           0.96     28909
   macro avg       0.84      0.84      0.83     28909
weighted avg       0.97      0.96      0.96     28909

<Figure size 700x600 with 2 Axes>
<Figure size 700x600 with 2 Axes>