Note
Go to the end to download the full example code.
Geographic Plot of Observations to look at QC#
This example demonstrates how to read an observation sequence file and plot the observations on a map, with the color indicating the QC value.
Import the modules
import os
import plotly.express as px
import pydartdiags.obs_sequence.obs_sequence as obsq
Read the obs_seq file into an obs_seq object.
In this example, we use a small obs_seq file “obs_seq.final.ascii.medium”
that comes with the pyDARTdiags package
in the data directory, so we use os
to get the path to the file
data_dir = os.path.join(os.getcwd(), "../..", "data")
data_file = os.path.join(data_dir, "obs_seq.final.ascii.medium")
obs_seq = obsq.ObsSequence(data_file)
Take a look at which columns are in the dataframe
obs_seq.df.columns
Index(['obs_num', 'observation', 'prior_ensemble_mean',
'prior_ensemble_spread', 'Data_QC', 'DART_quality_control',
'linked_list', 'longitude', 'latitude', 'vertical', 'vert_unit', 'type',
'metadata', 'external_FO', 'seconds', 'days', 'time', 'obs_err_var'],
dtype='object')
Plot the observations on a map. In this case, the colors of the points will indicate the DART quality control value and the hover data will show the observation number, the observation value, the type of observation, and the QC value. You can change the columns used for hover data and coloring. Refer to the columns in the dataframe to see your options.
fig = px.scatter_geo(
obs_seq.df,
lat='latitude',
lon='longitude',
color='DART_quality_control',
hover_data={'DART_quality_control':True,
'type': True,
'observation': True,
'obs_num': True
},
title='Geographic Plot of Latitude and Longitude'
)
fig.update_layout(
width=950, # Set the width of the plot
)
fig
Total running time of the script: (0 minutes 0.198 seconds)