The Road to Using Python with McIDAS-X

Slides:



Advertisements
Similar presentations
Using Macros and Visual Basic for Applications (VBA) with Excel
Advertisements

Scripting McIDAS-X in a Python environment Kevin Hallock SSEC Datacenter Programmer September 10, McIDAS Users Group Meeting.
23-Jun-15Advanced Programming Spring 2002 bash Henning Schulzrinne Department of Computer Science Columbia University.
CS 497C – Introduction to UNIX Lecture 34: - Shell Programming Chin-Chih Chang
Guide to Linux Installation and Administration, 2e1 Chapter 6 Using the Shell and Text Files.
Shell Script Examples.
Using Macs and Unix Nancy Griffeth January 6, 2014 Funding for this workshop was provided by the program “Computational Modeling and Analysis of Complex.
Nic Shulver, Scripts and Batch files Scripting in Windows and Linux What is scripting? What is it for? DOS/Windows batch files.
Or CMD/BATCH.  Title this comand makes the cmd prompt’s title whatever you would like it to be.
UNIX Processes. The UNIX Process A process is an instance of a program in execution. Created by another parent process as its child. One process can be.
Chapter Nine Advanced Shell Scripting1 System Programming Advanced Shell Scripting.
Chapter 9 Scripting RMAN. Background Authors felt that scripting was a topic not covered well Authors wanted to cover both Unix/Linux and Windows environments.
Chapter 5 Bourne Shells Scripts By C. Shing ITEC Dept Radford University.
Compiled Matlab on Condor: a recipe 30 th October 2007 Clare Giacomantonio.
Additional UNIX Commands. 222 Lecture Overview  Multiple commands and job control  More useful UNIX utilities.
Advance Map Automation With Python
Running the Operational Codes for the Brahmaputra Tom Hopson.
1 Shell Scripting (C shell) SungHo Maeung 10/27/2000 Tutorial section Computer Science Lab.
UNIX Shell Script (1) Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
CVS – concurrent versions system Network Management Workshop intERlab at AIT Thailand March 11-15, 2008.
Agenda Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Review next lab assignments Break Out Problems.
Esri UC 2014 | Technical Workshop | Python Map Automation – Beyond the Basics of arcpy.mapping Jeff Barrette Jeff Moulds.
Univ. of TehranDistributed Operating Systems1 Advanced Operating Systems University of Tehran Dept. of EE and Computer Engineering By: Dr. Nasser Yazdani.
McIDAS Advisory Committee (MAC) Sponsored: Group Discussion Joleen Feltz McIDAS Advisory Committee Co-Chair from Kristopher Bedka + McIDAS Advisory.
40 Years and Still Rocking the Terminal!
Shell Scripting – Putting it All Together. Agenda Escaping Characters Wildcards Redirecting Output Chaining and Conditional Chaining Unnamed and Named.
1 Software. 2 What is software ► Software is the term that we use for all the programs and data on a computer system. ► Two types of software ► Program.
1 Day 18 Bash and the.files. 2 The.files ls shows you the files in your directory –Or at least most of them. –Some files are hidden. Try: ls –a –This.
Environment After log in into the system, a copy of the shell is given to the user Shell maintains an environment which is distinct from one user to another.
Innovation Intelligence ® 1 Chapter 4: Using TCL to Control the HyperMesh Session.
30 Copyright © 2009, Oracle. All rights reserved. Using Oracle Business Intelligence Delivers.
Extending MATLAB Write your own scripts and/or functions Scripts and functions are plain text files with extension.m (m-files) To execute commands contained.
Batch Files Flow of Control to Strengthen Copyright © by Curt Hill.
Batch Files More flow of control Copyright © by Curt Hill.
Chapter 16 Advanced Bourne Shell Programming. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Objectives To discuss numeric data processing.
Python: File Directories What is a directory? A hierarchical file system that contains folders and files. Directory (root folder) Sub-directory (folder.
Mainframe – Control-M Architecture.
Jeff Barrette Jeff Moulds
Tutorial of Unix Command & shell scriptS 5027
NEMO – Reformating tool
Chapter 11 Command-Line Master Class
SDI (Satellite Data Ingestor)
MCIDAS AND THE AVIATION WEATHER CENTER
e~Print - Innovative Ways We Use It
Guide To UNIX Using Linux Third Edition
Machine Learning Workshop
Shell Programming (ch 10)
Introduction to Programming the WWW I
Preparation for use of the GOES-R Advanced Baseline Imager (ABI)
CSE 303 Concepts and Tools for Software Development
Engineering Innovation Center
What is Bash Shell Scripting?
LING 408/508: Computational Techniques for Linguists
Python I/O.
Why McIDAS uses Client and Server Technology
Scott Mindock, Jonathan Beavers, Rick Kohrs
Learning Outcomes –Lesson 4
Exploring the Power of EPDM Tasks - Working with and Developing Tasks in EPDM By: Marc Young XLM Solutions
SSEC Satellite Data Services RabbitMQ Messaging System
Runtime Root feature Jason Kenny.
Python Map Automation – Beyond the Basics of arcpy.mapping
Python 19 Mr. Husch.
CSE 303 Concepts and Tools for Software Development
Linux Shell Script Programming
Python Map Automation – Beyond the Basics of arcpy.mapping
Preparation for Assignment 2
Python 19 Mr. Husch.
Final Project Geog 375 Daniel Hewitt.
Presentation transcript:

The Road to Using Python with McIDAS-X Rick Kohrs Space Science & Engineering Center - Datacenter McIDAS Users’ Group Meeting Madison, WI 14-17 November 2016

PYTHON mcenv BATCH McBASI MACRO 2

Python mcenv BATCH McBASI 3

Python mcenv BATCH 4

Python mcenv 5

Python 6

MACRO Originated with McIDAS-MVS and replaced by mcskeyin Sequential running of commands Required compiling (examples commands SP and SL) FORTRAN programming capabilities (still in McIDAS-XRD) .MDX CLE PREFIX= (CFIX) IF (CSCHM.EQ.'SVCA')THEN .MDX MIX T TD SPD PSL VIS PCP SNO WIN ID ZS ZCL ZCM ZCH GUS - THAE THA + - UNIT= X (CT) (CT) (CW) X X X X (CW) MDF= (MD) PREFIX= (CFIX) - FORMAT= F8.1 X X X K3 F8.1 F8.2 - DIVIDE= X X X X .1 DEV= (CDVC) (CDFILE) DERIVE= T TD PSL ZS ELSE .MDX MIX T TD PSL PRE VIS PCP SNO WIN ID ZS CIGH ZCL1 ZCL2 GUS - UNIT= X (CT) (CT) X X X X X (CW) MDF= (MD) PREFIX= (CFIX) - FORMAT= F8.1 X X K3 K3 F8.1 F8.2 - DIVIDE= X X X .1 .1 DEV= (CDVC) (CDFILE) DERIVE= T TD PSL ZS ENDIF 100 7

McBASI Originated with McIDAS-MVS Sequential running of commands No compiling needed Added basic programming capabilities McBASI Single character variable names! rem ? HURR name map source color size frame labcol rem ? name - Name of the storm (no default) 43 let q$=mid$(a$,1,4) if q$=eof$ close 20 : return if mid$(a$,1,2)="$$" close 20 : return if mid$(a$,1,3)=" " close 20 : return if a$="" close 20 : return print a$ if mid$(a$,25,1)="D" goto 44 keyin "ECHO DEV=T POSTIME.DOC A {";mid$(a$,7,3);mid$(a$,10,2);" UTC}" let x(i)=val(mid$(a$,16,4)) let z(I)=val(mid$(a$,30,3)) print x(i), y(i), z(i) if x(i)>n LET n=x(i) if x(i)<o LET o=x(i) goto 42 44 return 8

McBASI Originated with McIDAS-MVS Sequential running of commands No compiling needed Added basic programming capabilities McBASI Single character variable names! 9

BATCH BATCH $ 5 F F KTS MYBATCH.BAT Originated with McIDAS-PC/OS2 Sequential running of commands No compiling needed BATCH MDX CLE PREFIX=%1 SF 1 EG LWU DEL OUTPUT.TXT MDX MIX T TD SPD PSL VIS PCP SNO WIN ID ZS ZCL ZCM ZCH GUS - THAE THA UNIT= X %3 %4 %5 X X X %3 MDF= %2 PREFIX= %1 FORMAT= F8.1 X X X K3 F8.1 F8.2 DIVIDE= X X X X .1 DERIVE= T TD PSL ZS DEV=OUTPUT.TXT BATCH $ 5 F F KTS MYBATCH.BAT 10

mcenv Originated with McIDAS-X Sequential running of commands No compiling needed mcenv Added shell scripting capabilities Works well with cron #!/bin/bash export hr=$1 export jday=$2 export hour jday LOG=$ADMIN_DIR/model_${hr}${jday}.log export PATH=/home/oper/cronjobs/funded/magic_globe/bin/:$PATH exec >$LOG exec 2>>$LOG Cd $DATA_DIR mcenv -i 220 -g 32 -f 3@2048x4096 << 'EOF' dataloc.k ADD RTGRIDS $PRIMARY_GRID_SERVER run.k $hr FILE=MMF.MCB convert -resize 1024x512 -adjoin -delay 10 -loop 0 hourly*.jpg ${FINAL_DIR}/animate_model_forecast.gif EOF 11

Python Originated with McIDAS-X Sequential running of commands No compiling needed Shell scripting capabilities Added advanced programming capabilities Added netCDF capabilites and much more! satelliteFile = satellite + '.dat' outFile = os.path.join(dataPath,satelliteFile) outFileHandle = open(outFile,'w') mcenv = mcidasx.mcidas.mcenv() mcenv.logon('iiii ####') datalocString='ADD ' + group + ' ' + server datalocOut = mcenv.dataloc(datalocString) imglistString = group + '/' + descriptor + ' FORM=ALL ' imgcheckString = group + '/' + descriptor imglistOut = mcenv.imglist(imglistString) imglistOutput = mccmdout2list(imglistOut.stdout) 12

Python Originated with McIDAS-X Sequential running of commands No compiling needed Shell scripting capabilities Added advanced programming capabilities Added netCDF capabilites and much more! imglistOut = mcenv.imglist(imglistString) print (imglistOut.stdout) Image file directory listing for:EASTL/CONUS Pos Satellite/ Date Time Center Band(s) sensor Lat Lon --- ------------- ------------ -------- ---- ---- ------------ 23 G-13 IMG 15 NOV 16320 15:45:00 14 72 1-4,6 IMGLIST: done 13

Python Originated with McIDAS-X Sequential running of commands No compiling needed Shell scripting capabilities Added advanced programming capabilities Added netCDF capabilites and much more! with open("newfile.txt") as f: for line in f: print line open(10,"newfile.txt") 10 input @10,a$ print a$ if mid$(a$,1,4) = eof$ goto 20 goto 10 14

Python Originated with McIDAS-X Sequential running of commands No compiling needed Shell scripting capabilities Added advanced programming capabilities Added netCDF capabilites and much more! with open("newfile.txt") as f: for line in f: print line open(10,"newfile.txt") 10 input @10,a$ print a$ if mid$(a$,1,4) = eof$ goto 20 goto 10 15

SDI GRB Appliance Publish AMQP messages Ground Station GOES-R Rebroadcast GRB RabbitMQ Broker pda-doe.GOES.G16.ABI.adde.realtime.ncdf.band.end: '{"coverage": "CONUS", "message_type": "band", "title": "ABI L1b Radiances", "server_ip": "dcserve6.ssec.wisc.edu", "medium": "adde", "start_time": "2016-11-01 11:59:13.5", "path": "/data/goes/grb/goes16/2016/2016_11_01_306/abi/L1b/RadC/OR_ABI-L1b-RadC-M3C09_G16_s20163061159135_e20163061201519_c20163061201552.nc", "mode": "3", "satellite_ID": "G16", "status": "end", "instrument": "ABI", "server_type": "realtime", "adde_dataset": "TESTPDA/CONUS", "satellite_family": "GOES", "band": 9, "end_time": "2016-11-01 12:01:51.9", "satellite_location": "GOES-Test"}' JSON -> Dictionary ADDE Users AMQP Listener McIDAS-X Python IMGDISP IMGCOPY 16

Summary Basic Programming Help Section Compiling Shell Scripting MACRO McBASI BATCH mcenv Python Shell Scripting Advanced Programming Core Supported netCDF 2 1 1UNIX Shell Only 2Operating System Commands 3McIDAS-XRD – Next Release 3 If it’s not broke why fix it? If it needs fixing redevelop? If it’s new development try new tools! McIDAS 17

rem --- I'll assume that this job will no longer be necessary after rem --- the year 2099 ... rem --- Create variables for saving files let p$ = "/dev/fs/D/home/magicadmin/magic_planet/real-time/" let v$ = p$ + "vis/MP-VIS-" let i$ = p$ + "ir/MP-IR-" let w$ = p$ + "wv/MP-WV-" let m$ = p$ + "vis-convert/MP-VIS-" let n$ = p$ + "ir-convert/MP-IR-" let o$ = p$ + "wv-convert/MP-WV-" let d$ = "20" + mid$(b$,28,5) let t$ = mid$(b$,35,2) + mid$(b$,38,2) If it’s not broke why fix it? 18

If it’s needs fixing, redevelop? Windows Scheduler launch SUA Shell start mcenv session run McBASI program create image with McIDAS-X Commands run Windows batch file to convert image format 19

McIDAS-X Python If it’s needs fixing, redevelop? Windows Scheduler launch SUA Shell start mcenv session run McBASI program create image with McIDAS-X Commands run Windows batch file to convert image format McIDAS-X Python 20

Evaluate your existing code MACRO BATCH McBASI Python 21 9600 40000 ~1500 Rick's Lines of Code

Developers of McIDAS-X Python Thanks to: Developers of McIDAS-X Python Kevin Hallock and Jon Beavers 22

Questions 23