<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 <h2>Introducing miscellaneous utilities in AWOT.</h2>
<h4>This notebook will grow over time as utilites are added and I have time to update.</h4>
Step1:  <b> First we'll need some data to interact with</b>
Step2:  <b>Read in the radar data</b>
Step3:  <h3>Data instances</h3>
<b>Read a variable from another file and add it to the AWOT dictionary. A mask of invalid data is automatically applied. Additional masking can be accomplished by setting the <i>mask_value</i> keyword.</b>
Step4:  <b>Just as in the plotting routines, time can be subset using a date string. But maybe you want to just return a subsetted dicationary for use. The <i>time_subset_awot_dict</i> function does this.</b>
Step5:  <b>AWOT uses Py-ART to read many radar files. Therefore we can read through AWOT.</b>
Step6:  <b> By changing the <i>map_to_awot</i> key we can convert the Py-ART radar instance to an AWOT radar instance. Note this is the DEFAULT behavior to make working with the AWOT package a bit easier.</b>
Step7:  <b>An experimental KMZ file creation is available for flight data.</b>
Step8:  <b>Now we can create a KMZ file of the track. This saves a KMZ file to current working directory if not specified.</b>
<ASSISTANT_TASK:>
Python Code:
# Load the needed packages
import os
import matplotlib.pyplot as plt
import numpy as np
from netCDF4 import Dataset
import awot
%matplotlib inline
Explanation: <h2>Introducing miscellaneous utilities in AWOT.</h2>
<h4>This notebook will grow over time as utilites are added and I have time to update.</h4>
End of explanation
# Released data file
wcrf1 = os.path.join("/Users/guy/data/king_air/owles2013/wcr", "WCR.OWLES13.20131215.225944_234806.up-down.nc")
# Supplementary file with corrected velocity data
wcrf2 = os.path.join("/Users/guy/data/king_air/owles2013/wcr/", "W-CORRECTED.WCR.OWLES13.20131215.225944_234806.up-down.nc")
Explanation: <b> First we'll need some data to interact with</b>
End of explanation
wcr = awot.io.read_wcr2(fname=wcrf1)
Explanation: <b>Read in the radar data</b>
End of explanation
nc = Dataset(wcrf2)
velcor = nc.variables['Velocity_cor_2']
awot.util.add_dict_to_awot_fields(wcr, 'velocity_corrected', data=velcor[:],
                                 units=velcor.units, longname=velcor.long_name, stdname="Corrected velocity")
print(wcr['fields']['velocity']['data'].shape, wcr['fields']['velocity_corrected']['data'].shape)
print(np.ma.min(wcr['fields']['velocity']['data']), np.ma.max(wcr['fields']['velocity']['data']))
print(np.ma.min(wcr['fields']['velocity_corrected']['data']), np.ma.max(wcr['fields']['velocity_corrected']['data']))
Explanation: <h3>Data instances</h3>
<b>Read a variable from another file and add it to the AWOT dictionary. A mask of invalid data is automatically applied. Additional masking can be accomplished by setting the <i>mask_value</i> keyword.</b>
End of explanation
start_time = "2013-12-15 23:05:00"
end_time = "2013-12-15 23:15:00"
# Create subsets of arrays
refsub = awot.util.time_subset_awot_dict(wcr['time'], wcr['fields']['reflectivity'],
                                        start_time, end_time)
velsub = awot.util.time_subset_awot_dict(wcr['time'], wcr['fields']['velocity'],
                                        start_time, end_time)
altsub = awot.util.time_subset_awot_dict(wcr['time'], wcr['altitude'],
                                        start_time, end_time)
print(wcr['fields']['reflectivity']['data'].shape, refsub['data'].shape)
print(wcr['fields']['velocity']['data'].shape, velsub['data'].shape)
print(wcr['altitude']['data'].shape, altsub['data'].shape)
Explanation: <b>Just as in the plotting routines, time can be subset using a date string. But maybe you want to just return a subsetted dicationary for use. The <i>time_subset_awot_dict</i> function does this.</b>
End of explanation
nexf = os.path.join("/Users/guy/data/nexrad/KILN/nex2/20140429", "KILN20140430_004708_V06")
rnex = awot.io.read_ground_radar(nexf, map_to_awot=False)
rnex.fields.keys()
Explanation: <b>AWOT uses Py-ART to read many radar files. Therefore we can read through AWOT.</b>
End of explanation
rnex = awot.io.read_ground_radar(nexf, map_to_awot=True)
rnex.keys()
Explanation: <b> By changing the <i>map_to_awot</i> key we can convert the Py-ART radar instance to an AWOT radar instance. Note this is the DEFAULT behavior to make working with the AWOT package a bit easier.</b>
End of explanation
flname = os.path.join("/Users/guy/data/king_air/pecan2015", "20150716.c1.nc")
fl1 = awot.io.read_netcdf(fname=flname, platform='uwka')
Explanation: <b>An experimental KMZ file creation is available for flight data.</b>
End of explanation
awot.util.write_track_kmz(fl1, 'altitude', show_legend=False, end_time="2016-01-01T00:00:00")
Explanation: <b>Now we can create a KMZ file of the track. This saves a KMZ file to current working directory if not specified.</b>
End of explanation
<END_TASK>