Skip to content

Commit

Permalink
Merge 8375333 into 02c3186
Browse files Browse the repository at this point in the history
  • Loading branch information
Pica4x6 committed Nov 25, 2015
2 parents 02c3186 + 8375333 commit 7d32d5d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 12 deletions.
21 changes: 9 additions & 12 deletions megaradrp/products.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

"""Products of the Megara Pipeline"""


'''
RAW_BIAS DataFrameType
RAW_DARK DataFrameType
Expand Down Expand Up @@ -64,23 +63,21 @@ class MasterSensitivity(MEGARAProductFrame):


class TraceMap(DataProductType):

def __init__(self, default=None):
super(TraceMap, self).__init__(
ptype=dict, default=default)

def __numina_dump__(self, obj, where):
super(TraceMap, self).__init__(ptype=dict, default=default)

def _datatype_dump(self, obj, where):
filename = where.destination + '.yaml'

with open(filename, 'w') as fd:
yaml.dump(obj, fd)

return filename

def __numina_load__(tag, obj):

with open(obj, 'r') as fd:
traces = yaml.load(fd)

return traces
def _datatype_load(self, obj):
try:
with open(obj, 'r') as fd:
traces = yaml.load(fd)
except IOError as e:
raise e
return traces
37 changes: 37 additions & 0 deletions megaradrp/tests/test_products.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#
# Copyright 2015 Universidad Complutense de Madrid
#
# This file is part of Megara DRP
#
# Megara DRP is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Megara DRP is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Megara DRP. If not, see <http://www.gnu.org/licenses/>.
#

from megaradrp.products import TraceMap
from tempfile import NamedTemporaryFile
import pytest

@pytest.mark.xfail
def test_traceMap(benchmark=None):
my_obj = TraceMap()
my_obj._datatype_load('')

def test_traceMap(benchmark=None):
my_obj = TraceMap()
my_file =NamedTemporaryFile()
print (my_file.name)
my_open_file = my_obj._datatype_load(my_file.name)
print (my_open_file)

if __name__ == "__main__":
test_traceMap()

0 comments on commit 7d32d5d

Please sign in to comment.