File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,10 @@ def create_cfad(
7777 if field_mask is not None :
7878 field_data = np .ma .masked_where (field_mask , field_data )
7979 altitude_data = np .ma .masked_where (field_data .mask , altitude_data )
80+ else :
81+ if isinstance (field_data , np .ma .MaskedArray ):
82+ mask = field_data .mask
83+ altitude_data = np .ma .masked_where (mask , altitude_data )
8084
8185 # get raw bin counts
8286 freq , height_edges , field_edges = np .histogram2d (
Original file line number Diff line number Diff line change @@ -35,3 +35,25 @@ def test_cfad_default():
3535 assert freq_norm .all (axis = 0 ).any ()
3636 # check column 12 is all ones
3737 assert (freq_norm [:, verify_index ] == 1 ).all ()
38+
39+ # Test if code pulls mask from current array if no mask is provided
40+ non_masked_array = np .ones (radar .fields [ref_field ]["data" ].shape ) * 20
41+ mask = np .zeros (non_masked_array .shape , dtype = bool ) # Initialize with False
42+ mask [:] = True
43+
44+ masked_array = np .ma .array (non_masked_array , mask = mask )
45+
46+ # set every value to be masked
47+ radar .fields [ref_field ]["data" ] = masked_array
48+
49+ # calculate CFAD
50+ freq_norm , height_edges , field_edges = pyart .retrieve .create_cfad (
51+ radar ,
52+ field_bins = np .linspace (0 , 30 , 20 ),
53+ altitude_bins = np .arange (0 , 18000 , 100 ),
54+ field = "reflectivity" ,
55+ field_mask = None ,
56+ )
57+
58+ # Check if mask is working.
59+ assert np .isnan (freq_norm ).all () == np .True_ # Output: True
You can’t perform that action at this time.
0 commit comments