Comments (5)
@ajsockol can you post the code used to create the first plot?
from act.
# Import necessary standard libraries
from os import environ
import datetime as dt
import astral, act, pathlib
from dqlib.io.data import read_arm_data_act
from dqlib.utils.utils import DatastreamParser, string_dates
from dqlib.io.image import save_plot
def plot_module(run_parameters, ds_object, days=0):
#Get all the file parameters and metadata needed for processing
#Get AMC Data
filename = run_parameters['filename']
params = DatastreamParser(filename)
date = params.date
datastream = params.datastream_standard
site = params.site
platform = params.datastream_class
facility = params.facility
level = params.level
data_path = run_parameters['base_data_path']
#Sets default x-range to one day
xrng = [(dt.datetime.strptime(date,'%Y%m%d') -
dt.timedelta(days=days)),
(dt.datetime.strptime(date,'%Y%m%d') +
dt.timedelta(days=1))]
#If keyword day is > 0, then weekly plots are made
if days > 0:
sdate, edate = tuple(string_dates(xrng, format='full'))
ds_object = read_arm_data_act(
datastream, startdate=sdate, enddate=edate,
basepath=data_path)
plotname = 'SRG_weekly'
else:
plotname = 'SRG_daily'
# ----------------------------------
# Plot data
# ----------------------------------
#Make SRG Plots
#Create figure and set size by multiplying figheight
#by the number of figures to plot from subplot_shape
figwidth = 10 # width of figure in pixels. 9 = 900 pixels
figheight = 3 # height of figure in pixels. 3 = 300 pixels
subplot_shape = (3, ) #Number of plots in figure
#Use ACT time series display
display = act.plotting.TimeSeriesDisplay(
{datastream:ds_object}, subplot_shape=subplot_shape,
figsize=(figwidth, subplot_shape[0]*figheight))
display.fig.tight_layout()
display.fig.subplots_adjust(left=0.1,right=0.85,bottom=0.08,
top=0.95,hspace=0.3)
var_names = ['battery_voltage_min','panel_temperature','siphon_rain_gauge_adc']
subplot_titles = ['Minimum Battery Voltage','Panel Temperature',
'Instantaneous Precipitation Amount of Siphon Gauge']
subplot_indices = [0,1,2]
for ii, var in enumerate(var_names):
subplot_index = subplot_indices[ii]
display.plot(var, subplot_index=(subplot_index, ), label=var)
leg2 = display.axes[subplot_index].legend(loc='center left', bbox_to_anchor=(0.99, 0.5),prop={'size':8},
frameon=False, markerscale=0, handlelength=0)
for line, text in zip(leg2.get_lines(), leg2.get_texts()):
text.set_color(line.get_color())
display.axes[subplot_index].autoscale(tight=False,axis='y')
display.axes[subplot_index].set_xlim(xrng)
if days > 0:
display.axes[subplot_index].set_title(datastream + ' ' + subplot_titles[subplot_index] + ' from ' + sdate + ' to ' + date)
else:
display.axes[subplot_index].set_title(datastream + ' ' + subplot_titles[subplot_index] + ' on ' + date)
try:
display.day_night_background(datastream, subplot_index=(subplot_index, ))
except (AttributeError, ValueError, astral.AstralError):
pass
#Create and save plots as png files
imagename = '.'.join([datastream,plotname,date,'png'])
imagename = pathlib.Path(environ['DQPLOT_DATA'], site, site+platform,
date, imagename)
save_plot(display.fig, imagename=imagename, run_parameters=run_parameters)
from act.
@ajsockol I think I figured it out. The data are first plotting for 1-2 days, so the x-format is based on those 2 days. You then adjust the xrng after the plotting and don't adjust the format. 2 options
-
add the following
myFmt = common.get_date_format(days)
display.axes[subplot_index].xaxis.set_major_formatter(myFmt) -
Pass your xrng to the plot call using time_rng that was added at some point.
display.plot('battery_voltage_min', time_rng=xrng)
Option number 2 is much simpler it looks like.
from act.
from act.
@AdamTheisen Thanks! I think I fixed it. All good now. We can probably close this Issue out.
from act.
Related Issues (20)
- Error while using add_dqr_to_qc: flag_values and flag_masks not set as expected HOT 9
- Make version 2.0 release prominent on landing page HOT 1
- arm_site_location_search - varying output HOT 5
- Streaking with missing data in 2D plots HOT 1
- Secondary Y-Display breaks convention with Matplotlib
- Verify that unit tests for plotting are comparing and doing what it's supposed to. HOT 6
- Add Hysplit data support HOT 1
- Add examples for working with INP/Aerosol data HOT 5
- Support for Aerial Measurements (UAS, Aircraft, TBS) HOT 7
- ACT does not support QC format from ARM's new Simple QC Feature in Data Discovery HOT 2
- add_dqr_to_qc not working properly HOT 2
- Rename CSV submodule HOT 8
- Add warning to change units when fails HOT 1
- Migrating PPI/Lidar etc Data to xradar
- ASOS Download Change HOT 1
- Bug in xsection plot map code
- Feature Request: Shared X axis for time-series
- ACT Documentation Updates HOT 3
- GeographicPlotDisplay documentation missing description of return value HOT 5
- AmeriFlux Documentation is not showing up in the API HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from act.