Commit 18d780cd authored by bepinat's avatar bepinat

Possiblity to open files from command line added

parents d026cbd4 f5d30bb4
Pipeline #1067 canceled with stages
......@@ -134,6 +134,73 @@ TRAILER_AD3 = [
('comment', np.int8, 128) # 31 -- unused
]
DEFAULTS_TRAILER_AD2 = {
'nbdim': 2,
'id1': 1,
'id2': 1,
# 'lx': 0,
# 'ly': 0,
# 'lz': 0,
'scale': 1.0,
'ix0': 1,
'iy0': 1,
'zoom': 1.0,
'modevis': 1,
'thrshld': 1.0,
'step': 1.0,
'nbiso': 1,
'pal': 1,
'cdelt1': 1.0,
'cdelt2': 1.0,
'crval1': 1.0,
'crval2': 1.0,
'crpix1': 1.0,
'crpix2': 1.0,
'crota2': 0.0,
'equinox': 0.0,
'x_mirror': 0,
'y_mirror': 0,
'was_compressed': 0,
'none2': 1,
'none': 0,
'comment': 1
}
DEFAULTS_TRAILER_AD3 = {
"nbdim": 3,
"id1": 1,
"id2": 1,
#"lx": 0,
#"ly": 0,
#"lz": 0,
"scale": 1.0,
"ix0": 1,
"iy0": 1,
"zoom": 1.0,
"xl1": 1.0,
"xil": 1.0,
"vr0": 0.0,
"corrvadh": 0.0,
"p0": 0.0,
"xlp": 0.0,
"xl0": 0.0,
"vr1": 0.0,
"xik": 0.0,
"cdelt1": 1.0,
"cdelt2": 1.0,
"crval1": 1.0,
"crval2": 1.0,
"crpix1": 1.0,
"crpix2": 1.0,
"crota2": 0.0,
"equinox": 0.0,
"x_mirror": 1,
"y_mirror": 1,
"was_compressed": 0,
'none2': 1,
'comment': 1,
}
SAMI_HEADER_KEYS = [
'OBJECT',
'OBSTYPE',
......@@ -353,6 +420,9 @@ class TDU:
trailer['ly'] = data.shape[0]
trailer['lz'] = 1
for key in DEFAULTS_TRAILER_AD2.keys():
trailer[key] = DEFAULTS_TRAILER_AD2[key]
elif ndim == 3:
dt = np.dtype(TRAILER_AD3)
trailer = np.ones((1,), dtype=dt)[0]
......@@ -361,6 +431,9 @@ class TDU:
trailer['ly'] = data.shape[1]
trailer['lz'] = data.shape[0]
for key in DEFAULTS_TRAILER_AD3.keys():
trailer[key] = DEFAULTS_TRAILER_AD3[key]
else:
raise ValueError('Invalid number of dimensions. Expected 2 or 3. '
'Found {}'.format(ndim))
......@@ -432,13 +505,6 @@ class TDU:
def ndim(self):
return self.data.ndim
@property
def xyz(self):
return self._xyz
@xyz.setter
def xyz(self, _xyz):
self._xyz = _xyz
def ad2_trailer():
raise NotImplemented
......
......@@ -126,21 +126,19 @@ class TestAd2Io(TestCase):
self.assertEqual(data.shape[0], tdu.trailer['ly'])
self.assertEqual(1, tdu.trailer['lz'])
dummy_parameters = ['id1', 'id2', 'scale', 'ix0', 'iy0', 'zoom',
'modevis', 'thrshld', 'step', 'nbiso', 'pal',
'cdelt1', 'cdelt2', 'crval1', 'crval2', 'crpix1',
'crpix2', 'crota2', 'equinox', 'x_mirror',
'y_mirror', 'was_compressed', 'none2', 'none',
'comment']
for key in pyadhoc.DEFAULTS_TRAILER_AD2.keys():
for p in dummy_parameters:
np.testing.assert_array_equal(1, tdu.trailer[p])
np.testing.assert_array_equal(
pyadhoc.DEFAULTS_TRAILER_AD2[key], tdu.trailer[key],
err_msg='Inconsistent value for parameter {:s}'.format(key)
)
tdu.writeto(
os.path.join(self.test_data_path, 'ndarray.ad2'),
overwrite=True
)
class TestAd3Io(TestCase):
test_data_path = "tests/data"
......@@ -241,14 +239,12 @@ class TestAd3Io(TestCase):
self.assertEqual(data.shape[1], tdu.trailer['ly'])
self.assertEqual(data.shape[0], tdu.trailer['lz'])
dummy_parameters = ["id1", "id2", "scale", "ix0", "iy0", "zoom", "xl1",
"xil", "vr0", "corrvadh", "p0", "xlp", "xl0", "vr1",
"xik", "cdelt1", "cdelt2", "crval1", "crval2",
"crpix1", "crpix2", "crota2", "equinox", "x_mirror",
"y_mirror", "was_compressed", 'none2', 'comment']
for key in pyadhoc.DEFAULTS_TRAILER_AD3.keys():
for p in dummy_parameters:
np.testing.assert_array_equal(1, tdu.trailer[p])
np.testing.assert_array_equal(
pyadhoc.DEFAULTS_TRAILER_AD3[key], tdu.trailer[key],
err_msg='Inconsistent value for parameter {:s}'.format(key)
)
tdu.writeto(
os.path.join(self.test_data_path, 'ndarray.ad3'),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment