Giter VIP home page Giter VIP logo

archapp's Introduction

archapp

PCDS conda Python environments already include archapp.

In order to access the archiver interactively, use the following:

Source the environment first:

$ source /cds/group/pcds/pyps/conda/pcds_conda

And then start IPython:

$ ipython

Import a helper class that lets you access the archiver:

from archapp.interactive import EpicsArchive

Now create a reusable object that will let you access our photon-side archiver:

arch = EpicsArchive()

To get data, use the following:

data = arch.get("pv_name", xarray=True)

It's recommended to use xarray=True in order to get an easy-to-use time series array back.

To get the data as a pandas data frame, you can use:

df = data.to_dataframe()

To get just values (or alarm status) from the data frame, use the following:

df = data.to_dataframe()
values = df["pv_name"].vals
alarm_stat = df["pv_name"].stat

To resample the values to just once per day, interpolating linearly (common alternative options may include "quadratic" or "cubic" or "nearest"):

data.resample(time="1D").interpolate("linear")

To merge data from different PVs - using a real pair for example - one option may be the following:

In [1]: m1 = arch.get("AT2K2:L2SI:MMS:01.RBV", xarray=True).resample(time="1D").interpolate("linear").to_dataframe()

In [2]: m2 = arch.get("AT2K2:L2SI:MMS:02.RBV", xarray=True).resample(time="1D").interpolate("linear").to_dataframe()

In [3]: m1.merge(m2, left_index=True, right_index=True)[:10]
Out[3]:
                 AT2K2:L2SI:MMS:01.RBV AT2K2:L2SI:MMS:02.RBV
field time
vals  2021-08-09                26.994              27.71345
      2021-08-10                26.994              27.71345
      2021-08-11               26.9939              27.71345
      2021-08-12               26.9939              27.71345
      2021-08-13               26.9939               27.7134
      2021-08-14               26.9939              27.71325
      2021-08-15               26.9939              27.71335
      2021-08-16              26.99395              27.71335
      2021-08-17                26.994               27.7135
      2021-08-18                26.994              27.71345

Usage outside of PCDS environments

Create a conda environment that uses python 3. Make sure xarray is installed in the conda environment.

Go to archapp/lib and type ipython in the command line.

archapp's People

Contributors

zllentz avatar klauer avatar zrylettc avatar n-wbrown avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.