<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Reading a file using CF module
The main difference with the previous example is the way we will read the data from the file.
Instead of the netCDF4 module, we will use the cf-python package, which implements the CF data model for the reading, writing and processing of data and metadata.
Step1:  The data file is the same.
Step2:  Read the file
We use the function read. Doing so, we easily obtain a nice summary of the file content.
Step3:  We see that the file contains 4 variables
Step4:  The number of variables which have a standard name corresponding to sea_water_temperature is
Step5:  but in other cases (ex
Step6:  We inspect the corresponding coordinates
Step7:  To extract the time variable
Step8:  and to get the values
Step9:  A simple plot
<ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import cf
import netCDF4
import matplotlib.pyplot as plt
Explanation: Reading a file using CF module
The main difference with the previous example is the way we will read the data from the file.
Instead of the netCDF4 module, we will use the cf-python package, which implements the CF data model for the reading, writing and processing of data and metadata.
End of explanation
dataurl = "http://thredds.socib.es/thredds/dodsC/mooring/conductivity_and_temperature_recorder/buoy_canaldeibiza-scb_sbe37006/L1/dep0003_buoy-canaldeibiza_scb-sbe37006_L1_latest.nc"
Explanation: The data file is the same.
End of explanation
f = cf.read(dataurl)
print f
Explanation: Read the file
We use the function read. Doing so, we easily obtain a nice summary of the file content.
End of explanation
temperature = f.select('sea_water_temperature')
temperature
Explanation: We see that the file contains 4 variables: 
1. temperature
2. salinity
3. conductivity.
Each of them has 4 dimensions: longitude, latitude, time and depth.
Read variable, coordinates and units
From the previous commands we cannot know the name of the variables within the file. But that's not necessary. Temperature can be retrived using its standard name:
End of explanation
print len(temperature)
Explanation: The number of variables which have a standard name corresponding to sea_water_temperature is:
End of explanation
temperature_values = temperature[0].array
temperature_units = temperature[0].units
print temperature_values[0:20]
print 'Temperature units: ' + temperature_units
Explanation: but in other cases (ex: different sensors measuring temperature with data in a common file), one can obtain more than one variable.
To get the temperature values, we select the first element (index = 0 in python, not 1) and convert it into an array.
End of explanation
temperature[0].coords()
Explanation: We inspect the corresponding coordinates:
End of explanation
time = temperature[0].coord('time')
time
Explanation: To extract the time variable:
End of explanation
time_values = temperature[0].coord('time').array
time_units = temperature[0].coord('time').units
print time_values[0:20]
print ' '
print 'Time units: ' + time_units
Explanation: and to get the values:
End of explanation
time2 = netCDF4.num2date(time_values, time_units)
plt.plot(time2, temperature_values)
plt.ylabel(temperature_units, fontsize=20)
plt.show()
Explanation: A simple plot
End of explanation
<END_TASK>