Module FITS
[hide private]
[frames] | no frames]

Source Code for Module FITS

 1  # Copyright (C) 2005 Joint Institute for VLBI in Europe 
 2  # Copyright (C) 2005 Associated Universities, Inc. Washington DC, USA. 
 3  # 
 4  # This program is free software; you can redistribute it and/or modify 
 5  # it under the terms of the GNU General Public License as published by 
 6  # the Free Software Foundation; either version 2 of the License, or 
 7  # (at your option) any later version. 
 8  # 
 9  # This program is distributed in the hope that it will be useful, 
10  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
11  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
12  # GNU General Public License for more details. 
13   
14  # You should have received a copy of the GNU General Public License 
15  # along with this program; if not, write to the Free Software 
16  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
17   
18  """ 
19   
20  This module provides the FITSDisk and FITS classes.   
21   
22  """ 
23   
24  # Generic Python stuff. 
25  import os 
26   
27  # Available proxies. 
28  import LocalProxy 
29  from xmlrpclib import ServerProxy 
30   
31   
32 -class FITSDisk:
33 34 """Class representing a (possibly remote) FITS disk. An instance 35 of this class stores an FITS disk number and the URL of the 36 proxy through which it can be accessed. For local FITS disks 37 the URL will be None.""" 38
39 - def __init__(self, url, disk):
40 self.url = url 41 self.disk = disk
42
43 - def proxy(self):
44 """Return the proxy through which this FITS disk can be 45 accessed.""" 46 if self.url: 47 return ServerProxy(self.url) 48 else: 49 return LocalProxy
50 51
52 -class FITS:
53 54 """Container for several FITS-related default values. 55 Uses environment variables: FITS, FITS01, FITS02... 56 """ 57 58 # List of available proxies. 59 proxies = [ LocalProxy ] 60 61 # FITS disk mapping. 62 disks = [ None ] # Disk numbers are one-based. 63 64 # Look for FITS 65 area = 'FITS' 66 if area in os.environ: 67 disks.append(FITSDisk(None, 1)) 68 69 # FITS01, FITS02... 70 # Who will ever need more than 19 FITS disks? 71 for disk in xrange(2, 20): 72 area = 'FITS%02d' % (disk-1) 73 if not area in os.environ: 74 break 75 disks.append(FITSDisk(None, disk)) 76 continue 77 78 # Message log. 79 log = None
80