eff_parsid.py
2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
title = "ParSid"
tip = "Shows parallactic angle and sidereal time maps"
onein = -1
import copy as cp
import numpy as np
from guidata.qt.QtGui import QMessageBox
from guidata.dataset.datatypes import DataSet
from guidata.dataset.dataitems import (IntItem, StringItem, ChoiceItem, FloatItem, BoolItem)
from guiqwt.config import _
class NOD3_App:
def __init__(self, parent):
self.parent = parent
self.parent.activateWindow()
def compute_app(self, **args):
class FuncParam(DataSet):
s = StringItem('s', default="string")
i = IntItem('i', default=0, max=100, min=0)
a = FloatItem('a', default=1.)
b = BoolItem("bool", default=True)
choice = ChoiceItem("Unit", ("Degree", "Arcmin", "Arcsec"), default=2)
name = title.replace(" ", "")
if args == {}:
param = FuncParam(_("Title"), "description")
else:
param = self.parent.ScriptParameter(name, args)
# if no parameter needed set param to None. activate next line
param = None
self.parent.compute_11(name, lambda m, p: self.function(m, p), param, onein)
def Error(self, msg):
QMessageBox.critical(self.parent.parent(), title,
_(u"Error:")+"\n%s" % str(msg))
def function(self, m, p):
n = cp.copy(m)
n.header = m.header.copy()
maps = []
try:
parfound = False
sidfound = False
if hasattr(m, 'parmap'):
parfound = True
n.data = m.parmap
n.header["OBJECT"] = "Parallactic Angle Map"
maps.append(n)
if hasattr(m, 'sidmap'):
sidfound = True
m.data = m.sidmap
m.header["OBJECT"] = "Sidereal Time Map"
maps.append(m)
if not sidfound and not parfound:
self.Error("sorry, no parallactic angle or/and sidereal map available")
return [], p
except AttributeError:
self.Error("sorry, no parallactic angle or/and sidereal map available")
return [], p
return maps, p