Tools and Techniques for Developing Atmospheric Python Software: Insight from the Python ARM Radar Toolkit



Similar documents
Exercise 0. Although Python(x,y) comes already with a great variety of scientic Python packages, we might have to install additional dependencies:

3.5 THREE-DIMENSIONAL HIGH-RESOLUTION NATIONAL RADAR MOSAIC

Optimizing and interfacing with Cython. Konrad HINSEN Centre de Biophysique Moléculaire (Orléans) and Synchrotron Soleil (St Aubin)

CIS 192: Lecture 13 Scientific Computing and Unit Testing

Technical Report. An Interactive Iso-Surface Based 3D Weather Radar Data Visualization Package Using VisAD for WDSSII

MYPY: A PYTHON VARIANT WITH SEAMLESS DYNAMIC AND STATIC TYPING. Jukka Lehtosalo University of Cambridge Computer Laboratory

CRASH COURSE PYTHON. Het begint met een idee

ANSA and μeta as a CAE Software Development Platform

Intro to scientific programming (with Python) Pietro Berkes, Brandeis University

Assignment 2: Option Pricing and the Black-Scholes formula The University of British Columbia Science One CS Instructor: Michael Gelbart

Objects and classes. Objects and classes. Jarkko Toivonen (CS Department) Programming in Python 1

Profiling, debugging and testing with Python. Jonathan Bollback, Georg Rieckh and Jose Guzman

Object Oriented Software Design II

BSc (Hons) Business Information Systems, BSc (Hons) Computer Science with Network Security. & BSc. (Hons.) Software Engineering

Reprojecting MODIS Images

Continuous Integration/Testing and why you should assume every change breaks your code

Performance Testing for GDB

Software Tool Seminar WS Taming the Snake

The Clean programming language. Group 25, Jingui Li, Daren Tuzi

GCalc 2.1. GDA94 Datum Transformation DLL Technical Specification

Survey of Unit-Testing Frameworks. by John Szakmeister and Tim Woods

U N C L A S S I F I E D

An introduction to Python Programming for Research

A Comparison of Functional and Imperative Programming Techniques for Mathematical Software Development

Scientific Data Management and Dissemination

dedupe Documentation Release Forest Gregg, Derek Eder, and contributors

NetworkX: Network Analysis with Python

MountainZebra: Real-Time Archival and 4D Visualization of Radar Volumes Over Complex Terrain

pyownet Documentation

Python for Scientific Computing.

The P3 Compiler: compiling Python to C++ to remove overhead

2! Multimedia Programming with! Python and SDL

DevKey Documentation. Release 0.1. Colm O Connor

Visualization of Climate Data in R. By: Mehrdad Nezamdoost April 2013

Python. Python. 1 Python. M.Ulvrova, L.Pouilloux (ENS LYON) Informatique L3 Automne / 25

socketio Documentation

monoseq Documentation

Tellurium and libroadrunner in a Nutshell

The C Programming Language course syllabus associate level

Scientific Visualization with wxpython and Matplotlib. Scott Pearse CSCI 5448 Spring 2011

Flask-SSO Documentation

Open-Source-based Visualization of Flight Waypoint Tracking Using Flight Manipulation System

Alexandru Csete (Rovsing A/S) 3. International Workshop on Astrodynamics Tools and Techniques ESTEC, October 2-5, 2006

Wrestling with Python Unit testing. Warren Viant

INTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011

Problems and Measures Regarding Waste 1 Management and 3R Era of public health improvement Situation subsequent to the Meiji Restoration

THE proper modeling of a photovoltaic (PV) system

CS 241 Data Organization Coding Standards

DATA SCIENCE CURRICULUM WEEK 1 ONLINE PRE-WORK INSTALLING PACKAGES COMMAND LINE CODE EDITOR PYTHON STATISTICS PROJECT O5 PROJECT O3 PROJECT O2

C++ Class Library Data Management for Scientific Visualization

PCL Tutorial: The Point Cloud Library By Example. Jeff Delmerico. Vision and Perceptual Machines Lab 106 Davis Hall UB North Campus.

2/1/2010. Background Why Python? Getting Our Feet Wet Comparing Python to Java Resources (Including a free textbook!) Hathaway Brown School

NetCDF and HDF Data in ArcGIS

Software Architecture Document (SAD) for the Interferometric Modules of the Next ESA SAR Toolbox (NEST)

Thomas Jefferson High School for Science and Technology Program of Studies Foundations of Computer Science. Unit of Study / Textbook Correlation

Visualization with ParaView. Greg Johnson

Advanced Software Testing

CSCI E 98: Managed Environments for the Execution of Programs

Using EDA Databases: Milkyway & OpenAccess

8.5. <summary> Cppcheck addons Using Cppcheck addons Where to find some Cppcheck addons

Nicolas P. Rougier PyConFr Conference 2014 Lyon, October 24 25

A Statistical Framework for Operational Infrasound Monitoring

Application Note 49. Using the Digi TransPort Fleet Card. October 2011

PyLmod Documentation. Release MIT Office of Digital Learning

Introduction to Native Android Development with NDK

PATRIOT MISSILE DEFENSE Software Problem Led to System Failure at Dhahran, Saudi Arabia

Object Oriented Software Design II

:Introducing Star-P. The Open Platform for Parallel Application Development. Yoel Jacobsen E&M Computing LTD

Open Source Visualisation with ADAGUC Web Map Services

CSC230 Getting Starting in C. Tyler Bletsch

Lecture 10: Dynamic Memory Allocation 1: Into the jaws of malloc()

Software Engineering Concepts: Testing. Pointers & Dynamic Allocation. CS 311 Data Structures and Algorithms Lecture Slides Monday, September 14, 2009

Help on the Embedded Software Block

VOC Documentation. Release 0.1. Russell Keith-Magee

Using AllJoyn with Apache Cordova, Python & Node

Automated ETL Testing with Py.Test. Kevin A. Smith Senior QA Automation Engineer Cambia Health Solutions

Getting Started with the Internet Communications Engine

flask-mail Documentation

Obtaining and Processing MODIS Data

An Eprints Apache Log Filter for Non-Redundant Document Downloads by Browser Agents

Application Note AN0008. Data Logging Extension. For. Venus 8 GPS Receiver

WSR - Weather Surveillance Radar

Python programming guide for Earth Scientists. Maarten J. Waterloo and Vincent E.A. Post

Introduction to FreeNAS development

GDB Tutorial. A Walkthrough with Examples. CMSC Spring Last modified March 22, GDB Tutorial

Writing robust scientific code with testing (and Python) Pietro Berkes, Enthought UK

Big Data: Using ArcGIS with Apache Hadoop. Erik Hoel and Mike Park

Visualizing Multi-Dimensional WMS within ArcGIS For JavaScript API

Transcription:

Tools and Techniques for Developing Atmospheric Python Software: Insight from the Python ARM Radar Toolkit Jonathan Helmus1, Scott Giangrande2, Kirk North3, and Scott Collis1 1 2 Argonne National Laboratory Brookhaven National Laboratory 3 McGill University

Introduction to Py-ART

Py-ART: Plotting import matplotlib.pyplot as plt import matplotlib.pyplot as plt import pyart import pyart radar = pyart.io.read('xsw110520105408.raw7hhf') radar = pyart.io.read('xsw110520113537.raw7hhl') display = pyart.graph.radardisplay(radar) display = pyart.graph.radardisplay(radar) display.plot('reflectivity', 0, vmin=-32, vmax=64.) display.plot('reflectivity', 0, vmin=0, vmax=54.) plt.savefig('ppi_plot.png') display.set_limits(ylim=(0, 8)) plt.savefig('rhi_plot.png')

Py-ART: Correct - Doppler Velocity Dealiasing from pyart.correct import dealias_fourdd dealias_data = dealias_fourdd(radar, height * 1000., speed, direction, target) radar.add_field('corrected_velocity', dealias_data) Dealiasing performed using U. Washington FourDD algorithm (James and Houze, JTech, 2001)

Py-ART: Correct - LP phase processing import pyart radar = pyart.io.read('095636.mdv') phidp, kdp = pyart.correct.phase_proc_lp(radar, 0.0) radar.add_field('corrected_differential_phase', phidp) radar.add_field('corrected_specific_diff_phase', kdp) Phase processing performed using a LP based algorithm (Giangrande et al, JTech, 2013)

Py-ART: Mapping to Cartesian Grids import pyart radar_sw = pyart.io.read(xsapr_sw_file) radar_se = pyart.io.read(xsapr_se_file) grid = pyart.map.grid_from_radars((radar_se, radar_sw), grid_shape=(1, 201, 201), grid_limits=((1000, 1000), (-50000, 40000), (-60000, 40000)), grid_origin = (36.57861, -97.363611), max_refl=100.) Gridding using KD-Tree nearest neighbor lookup and Cressman interpolation.

Building Py-ART: SciPy Stack and other libraries

Building Py-ART: Interfacing with legacy code Cython files (.pyx,.pxd) Cython C file (.c) C Compiler (gcc) Compiled Python module (.so) External libraries (*.so,.a)

Building Py-ART: Cython Example - Cython side cdef extern from "rsl.h": ctypedef struct Radar: cimport _rsl_h cdef class RslFile: Radar_header h cdef _rsl_h.radar * _Radar Volume **v cdef _rsl_h.volume * _Volume ctypedef struct Radar_header: def cinit (self, filename): int month, day, year self._radar = _rsl_h.rsl_anyformat_to_radar(filename) int hour, minute if self._radar is NULL: float sec raise IOError('file cannot be read.') def dealloc (self): ctypedef struct Volume: _rsl_h.rsl_free_radar(self._radar) Volume_header h Sweep **sweep def get_volume(self, int volume_number): rslvolume = _RslVolume() rslvolume.load(self._radar.v[volume_number]) return rslvolume Radar * RSL_anyformat_to_radar(char *infile) property month: void RSL_free_volume(Volume *v) void RSL_free_radar(Radar *r) def get (self): return self._radar.h.month def set (self, int month): _rsl_h.pxd self._radar.h.month = month _rsl_interface.pyx

Building Py-ART: Cython Example - Python side _rsl_interface.pyx _rsl_h.pxd >>> from pyart.io import _rsl_interface >>> rslfile = _rsl_interface.rslfile('xsw110520105408.raw') >>> print rslfile <pyart.io._rsl_interface.rslfile object at 0x107112d20> Cython >>> print rslfile.month 5 >>> rslfile.month = 12 >>> print rslfile.month 12 >>> _rsl_interace.c >>> volume = rslfile.get_volume(1) >>> print volume <pyart.io._rsl_interface._rslvolume object at 0x100493760> C Compiler (gcc) _rsl_interface.so rsl.so

Software Engineering: Version Control $ git log commit dca8e348ba7db19f675747e8b98acf987d634915 Author: Jonathan Helmus <jjhelmus@gmail.com> Date: Fri Jan 24 11:46:29 2014-0600 ENH: pyproj no longer an optional dependency pyproj is included in basemap, use the version commit 26c7a36dadfbdcc1c4e1dc1d8bfe188a073e08a4 Author: Jonathan Helmus <jjhelmus@gmail.com> Date: Mon Jan 20 15:49:15 2014-0600 TST: do not install cylp or cvxopt in python 2.6 commit 1eeed39faf89d4aa9eda6014c4dbc1a2458bbb9a Author: Jonathan Helmus <jjhelmus@gmail.com> Date: Mon Jan 20 15:42:24 2014-0600 TST: do not all basemap in python 2.6 commit d1ce060537df08aad39b8ad3a75db13a9728aa1a Author: Jonathan Helmus <jjhelmus@gmail.com> Date: Mon Jan 20 15:35:14 2014-0600 BUG: fixed bugs when running in Python 2.6

Software Engineering: Testing def test_radar_creation(): radar = pyart.testing.make_target_radar() assert isinstance(radar, pyart.io.radar) def test_add_field(): radar = pyart.testing.make_target_radar() dic = {'data': np.zeros((360, 50)), 'standard_name': 'test'} radar.add_field('test', dic) assert 'test' in radar.fields assert 'data' in radar.fields['test'] assert radar.fields['test']['standard_name'] == 'test' ~/python/pyart$ nosetests -v test_attenuation.test_attenuation ok test_dealias.test_find_time_in_interp_sounde ok test_config.test_filemetadata_custom ok test_config.test_init_load ok test_config.test_intergration ok ---------------------------------------------------------Ran 386 tests in 20.666s OK (SKIP=2)

Software Engineering: Continuous Integration

Software Engineering: Embedded Documentation def grid_from_radars(radars, grid_shape, grid_limits, **kwargs): """ Map one or more radars to a Cartesian grid returning a Grid object. Additional arguments are passed to :py:func:`map_to_grid` Parameters ---------radars : tuple of Radar Radar objects which grid_shape : 3-tuple of Number of points in objects. will be mapped to the Cartesian grid. floats the grid (z, y, x).

GitHub https://github.com/arm-doe/pyart

Py-ART: File I/O Format Native Read Read w/ RSL Sigmet/IRIS X X MDV X Cf/Radial X (+writing) Universal (UF) X Lassen X NEXRAD Level II DORAD X X

Radar 101 Top view Side view Gate Sweep Radial Radar Volume Sweep Sweep Sweep Radial Radial Radial Radial Gate Gate Gate Gate Gate

Py-ART: Data layout Radar object attributes Layout ngates : int nrays : int nsweeps : int scan_type : str Radar Sweep layout sweep_start_ray_index : dict sweep_end_ray_index : dict sweep_number : dict sweep_mode : dict fixed_angle: dict Dimensions time : dict range: dict azimuth : dict elevation : dict Location longitude : dict latitude: dict altitude : dict Fields : dict Optional metadata : dict radar_calibration : dict Field attribute keys The format of the Radar object closely follows the Cf/Radial format (Dixon et al) reflectivity : dict data : 2D array units : str spectral_width : dict data : 2D array units : str dopper_velocity : dict data : 2D array units : str differential_phase : dict data : 2D array units : str