eff_select1.py
2.34 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
65
66
title = "Select1"
tip = "selects all different map types"
onein = False
import numpy as np
from nod3fits import array_to_fits
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 Error(self, msg):
QMessageBox.critical(self.parent.parent(), title,
_(u"Error:")+"\n%s" % str(msg))
def compute_app(self, **args):
class FuncParam(DataSet):
#mtype = StringItem('Map-Type')
#i = IntItem('i', default=0, max=100, min=0)
#a = FloatItem('a', default=1.)
#b = BoolItem("bool", default=True)
mtype = ChoiceItem("Map-Type", (("I1", "I1"), ("I2", "I2"), ("U", "U"), ("Q", "Q"),
("I1,I2", "I1,I2"), ("U,Q", "U,Q"),
("Lon", "Lon"), ("Lat", "Lat")),
default = "I1")
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 function(self, ms, p):
mtypes = []
rows = self.parent._get_selected_rows()
i = -1
for m in ms:
if 'SCANDIR' in m.header and m.header['SCANDIR'] in ("LON", "ALON", "ULON", "GLON", "RA", "HA"):
scandir = "Lon"
elif 'SCANDIR' in m.header and m.header['SCANDIR'] in ("LAT", "ALAT", "ULAT", "GLAT", "DEC"):
scandir = "Lat"
else:
scandir = "None"
i += 1
if p.mtype in ("Lon", "Lat"):
mtype = scandir
else:
mtype = m.header['MAPTYPE']
row = rows[i]
if not mtype in p.mtype:
self.parent.listwidget.item(row).setSelected(False)
else:
self.parent.listwidget.item(row).setSelected(True)
return [], p