Astro-WISE Tutorial, Leiden 18-20 August 2008 Adapting Code Introduction to OOP Code, what code? What & where Why adapt code anyway? How?

Slides:



Advertisements
Similar presentations
Introduction To GIT Rob Di Marco Philly Linux Users Group July 14, 2008.
Advertisements

Understand and appreciate Object Oriented Programming (OOP) Objects are self-contained modules or subroutines that contain data as well as the functions.
Lilian Blot Announcements Teaching Evaluation Form week 9 practical session Formative Assessment week 10 during usual practical sessions group 1 Friday.
Lab III – Linux at UMBC.
1 CS 446 – Tutorial 6 Frid. Nov. 6 th, 2009 Implementation Tutorial.
Database System Concepts and Architecture
Executional Architecture
Chapter Modules CSC1310 Fall Modules Modules Modules are the highest level program organization unit, usually correspond to source files and.
1. What is Subversion? Why do we need CM? Basic concepts Repositories Options Setup Clients Options Setup Operation Troubleshooting Slide 2.
CVS Selim Çıracı Ahmet Kara Metin Tekkalmaz. CVS – Open Source Version Control System Outline What are Version Control Systems? And why do we need them?
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
The iiuf Java Package Part II Simon Schubiger and Oliver Hitz DIUF, University of Fribourg.
Low level CASE: Source Code Management. Source Code Management  Also known as Configuration Management  Source Code Managers are tools that: –Archive.
Hands-On Microsoft Windows Server 2008 Chapter 1 Introduction to Windows Server 2008.
1 Chapter One A First Program Using C#. 2 Objectives Learn about programming tasks Learn object-oriented programming concepts Learn about the C# programming.
SCRAM Software Configuration, Release And Management Background SCRAM has been developed to enable large, geographically dispersed and autonomous groups.
The Astro-Wise Pipeline Conceptual Design Review Roeland Rengelink Requirements Development Framework Prototype.
Customized cloud platform for computing on your terms !
1 © 2003, Cisco Systems, Inc. All rights reserved. CCNA 3 v3.0 Module 6 Switch Configuration.
1 © 2003, Cisco Systems, Inc. All rights reserved. CCNA 3 v3.0 Module 6 Switch Configuration.
By Zeng Sheng Liu. os - provides dozens of functions for interacting with the operating system >>> import os >>> os.system('time 0:02') 0 >>> os.getcwd()
An Introduction to Visual Basic
– Introduction to the Shell 10/1/2015 Introduction to the Shell – Session Introduction to the Shell – Session 2 · Permissions · Users.
The Pipeline Processing Framework LSST Applications Meeting IPAC Feb. 19, 2008 Raymond Plante National Center for Supercomputing Applications.
By: Joshua O’Donoghue. Operating System Interface In order to interact with the operating system in python you will want to become familiar with the OS.
Introduction to Python 2 Dr. Bernard Chen University of Central Arkansas PyArkansas 2011.
Python’s Standard Library - Part I Josh Lawrence.
1 Installation When this module is complete, you will be able to:  Set a static IP address for your laptop  Install the snom ONE software  Navigate.
Ch 1. A Python Q&A Session Spring Why do people use Python? Software quality Developer productivity Program portability Support libraries Component.
Progress with migration to SVN Part3: How to work with g4svn and geant4tags tools. Geant4.
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.
CSE 219 Computer Science III CVS
Python Programming Using Variables and input. Objectives We’re learning to build functions and to use inputs and outputs. Outcomes Build a function Use.
Astro-WISE workshop, 31/03 – 03/ Ewout Helmich Image Stacking in Astro-WISE ➢ Why this talk? ➢ Infrared data: lots of short exposures to stack.
_______________________________________________________________CMAQ Libraries and Utilities ___________________________________________________Community.
Virtual Survey System sept 04 ASTRO-WISE- federation OmegaCEN AstroWise a Virtual Survey System OmegaCAM – Lofar – AstroGrid –((G)A) VO AstroWise a Virtual.
How to use galfit (and galphot)
CVS – concurrent versions system AROC Guatemala July 19-23, 2010 Guatemala City, Guatemala.
Login & environment variable setting in CVS Presented by Pooja Jain.
WinCvs. WinCVS WinCvs is a window based version control system. Use WinCvs when  You want to save every version of your file you have ever created. CVS.
CMap Version 0.16 Ben Faga. CMap CMap Version 0.16 Bug fixes and code optimizations More intuitive menu system Asynchronous loading of comparative map.
Ch 1. A Python Q&A Session. Why do people use Python? Software Quality Developer productivity Program portability Support Libraries Component integration.
Réunion Contrôle Expérience 28/03/ Experiments Controls Vision, ideas, tasks to begin with … Alain Buteau Andy Götz.
Yannick Patois - Datagrid Software Repository Presentation - March, n° 1 Datagrid Software Repository Presentation CVS, packages and automatic.
Unified Noah LSM Code Management Using CVS Mukul Tewari 1, Mike Ek 2, Kevin Manning 1, Fei Chen 1 and Ken Mitchell 2 1 NCAR, Boulder, CO 2 NCEP/EMC, Camp.
Astro-Wise prompt ● awe is a shell with uses such as: – Python – data reduction (parallel, “dpu”) – interactive analysis (eclipse) – calculator – plotting.
Modules. Modules Modules are the highest level program organization unit, usually correspond to source files and serve as libraries of tools. Each file.
By: Aradhya Malhotra.  To interact with the OS in python you will want to become familiar with the OS module  The command “import os” is used for this.
Lecture Transforming Data: Using Apache Xalan to apply XSLT transformations Marc Dumontier Blueprint Initiative Samuel Lunenfeld Research Institute.
Review of PARK Reflectometry Group 10/31/2007. Outline Goal Hardware target Software infrastructure PARK organization Use cases Park Components. GUI /
Architecture Review 10/11/2004
Development Environment
CVS – concurrent versions system
USING PYTHON to Automate data management tasks
CVS – concurrent versions system
Using E-Business Suite Attachments
Intro to Python Programming – Part II
Introduction to Programming the WWW I
KFT1 Task 4 GETTING STARTED
Teach A-Level Computer Science: Object-Oriented Programming in Python
Instructor & Todd Lammle
CVS Concurrent Versioning System
Python’s Standard library part I
Instructor & Todd Lammle
DriveScale Log Collection Method of Procedure
Python Modules.
Automation of Control System Configuration TAC 18
Python Modules.
Presentation transcript:

Astro-WISE Tutorial, Leiden August 2008 Adapting Code Introduction to OOP Code, what code? What & where Why adapt code anyway? How?

Astro-WISE Tutorial, Leiden August 2008 Introduction to OOP (1) OOP is programming with classes Programming in the problem domain –Describe a problem in one sentence, then the nouns are the classes/objects: Lets reduce a bias of ccd50 of the WFI instrument –Classes are blue-prints describing real world things –Can also map to abstract things

Astro-WISE Tutorial, Leiden August 2008 Introduction to OOP (2) Advantages of using OOP: –Reuse of code –Readability of code –Bug tracking Important concepts: –Inheritance –Polymorphism

Astro-WISE Tutorial, Leiden August 2008 Structure of a class, members class Cat: age = 3.0 weight = 5.2 def miaw(self): print Miaw! def kill_other_cat(self, other):.... attribute method awe> cat = Cat() awe> cat.age 3.0 awe> cat.age = 5.0 awe> cat.age 5.0 object

Astro-WISE Tutorial, Leiden August 2008 Inheritance class Mammal: weight = -1 def breathe(self):.... class Cat(Mammal): def miaw(self): print Miaw! def kill_other_cat(self, other):.... inheritance cat = Cat() cat.breate()

Astro-WISE Tutorial, Leiden August 2008 Polymorphism class Cat(Mammal): def swim(self): # head up, move paws class Mammal: def swim(self):.... class Dolphin(Mammal): def swim(self): # head down, move fins polymorphism class Toddler(Mammal): def yell(self, txt): print txt.upper() + !! def swim(self): self.yell(I cant swim)

Astro-WISE Tutorial, Leiden August 2008 Getting a checkout CVS checkout = local copy of the code –Two versions: AWBASE and most recent Must use pserver to log in anonymously –User anoncvs, password >cvs –d cvs.astro-wise.org:/cvsroot co awe >cvs -d login ># base version >cvs -d checkout -r AWBASE awe

Astro-WISE Tutorial, Leiden August 2008 Using your own checkout Set environment AWEPIPE to point to the checkout directory (awe) > setenv AWEPIPE /data/users/helmich/awe (add to.cshrc)

Astro-WISE Tutorial, Leiden August 2008 Why adapt code? Hopefully not often necessary Make scripts to speed up process, and as a memory tool Create objects with your own methods

Astro-WISE Tutorial, Leiden August 2008 Directory structure Top level: awe common, astro, lofar, ai –Isolate specific code

Astro-WISE Tutorial, Leiden August 2008 Directory structure: common config| Startup and environment/configuration files database| Persistency mechanism and implementations of its interface log | Logging and messaging math | Mathematical Python routines such as statistics & least squares net | General network-related python modules services | Common (web-) services toolbox | Scripts for e.g. maintenance of the database, installation, etc. util | Routines for compression, checksumming, datetime manipulation.

Astro-WISE Tutorial, Leiden August 2008 Directory structure: astro config| Startup and environment/configuration files database | Astronomy specific database modules experimental| Experimental modules external | Python wrappers for tools such as LDAC, Sextractor and Swarp filerecipes | Data reduction recipes for use without database instrument | Instrument specific modules main | Modules for the pipeline processing of images plot | Various plotting modules recipes | Data reduction recipes (to create classes in "main") services | (Web-) services for astronomy test | Unittests toolbox | Scripts for ingestion, installation, various maintenance util | Utility modules usable throughout the code

Astro-WISE Tutorial, Leiden August 2008 Making a script (1/2) Based around dpu instance Based around a task As a sort of task Write the script in a file with.py extension Run with this command: > awe script.py

Astro-WISE Tutorial, Leiden August 2008 Making a script (2/2) Classes/models need to be imported Dotted (directory) structure: –from astro.recipes.Reduce import ReduceTask

Astro-WISE Tutorial, Leiden August 2008 Script based around dpu from astro.recipes.mods.dpu import Processor from astro.main.RawFrame import RawBiasFrame dpu = Processor('dpu.hpc.rug.astro-wise.org') ccd50 = [r.filename for r in RawBiasFrame.select(date=' ', instrument='WFI', chip='ccd50')] ccd51 = [r.filename for r in RawBiasFrame.select(date=' ', instrument='WFI', chip='ccd51')] dpu.run('Bias', instrument='WFI', raw_filenames=ccd50) dpu.run('Bias', instrument='WFI', raw_filenames=ccd51)

Astro-WISE Tutorial, Leiden August 2008 Script based around Task In particular to store configuration from astro.recipes.GalPhot import GalPhotTask from astro.util.Pars import Pars p=Pars(GalPhotTask) p.GalPhotModel.process_params.r1 = 10.0 p.GalPhotModel.process_params.dangmax=0.2 # etc. etc. task = GalPhotTask(instrument='WFI', slid=423431, sids=[16246], pars=p.get(), commit=0) task.execute()

Astro-WISE Tutorial, Leiden August 2008 Simple eclipse script Eclipse is used for image arithmetic import eclipse import glob filenames = glob.glob('*.red.fits') images = [eclipse.image.image(filename) for filename in filenames] cube = eclipse.cube.cube(images) median = cube.median() median.save('eclipse_med.fits')

Astro-WISE Tutorial, Leiden August 2008 Adapting classes ProcessTarget classes are located in astro.main –Lets look at BiasFrame: class BiasFrame(BaseFrame):.... def make_image(self).... cube = eclipse.cube.cube([raw.image for raw in self.raw_bias_frames]) # current method does an average with sigma rejection self.image = cube.median() # use a median instead