# Path: emirdrp/products.py
# class RefinedBoundaryModelParam(numina.types.structured.BaseStructuredCalibration):
#     """Refined parameters of MOS model
#     """
#     def __init__(self, instrument='unknown'):
#         super(RefinedBoundaryModelParam, self).__init__(instrument)
#         self.tags = {
#             'grism': "unknown",
#             'filter': "unknown"
#         }
#         self.contents = []
# 
#     def __getstate__(self):
#         state = super(RefinedBoundaryModelParam, self).__getstate__()
#         if six.PY2:
#             state['contents'] = copy.copy(self.contents)
#         else:
#             state['contents'] = self.contents.copy()
#         return state
# 
#     def __setstate__(self, state):
#         super(RefinedBoundaryModelParam, self).__setstate__(state)
#         if six.PY2:
#             self.contents = copy.copy(state['contents'])
#         else:
#             self.contents = state['contents'].copy()
# 
#     def tag_names(self):
#         return ['grism', 'filter']


import argparse
import json
import sys
import numina.types.qc
from numina.tools.arg_file_is_new import arg_file_is_new
from numina.tools.check_setstate_getstate import check_setstate_getstate
from emirdrp.products import RefinedBoundaryModelParam

    # optional arguments
    parser.add_argument("--echo",
                        help="Display full command line",
                        action="store_true")
    args = parser.parse_args(args)

    if args.echo:
        print('\033[1m\033[31m% ' + ' '.join(sys.argv) + '\033[0m\n')

    # ---

    # read input JSON file
    input_json = json.loads(open(args.input_json.name).read())

    # generate object of type RefinedBoundaryModelParam from input JSON file
    refined_boundary_model = RefinedBoundaryModelParam(instrument='EMIR')
    refined_boundary_model.tags = {
        'grism': input_json['tags']['grism'],
        'filter': input_json['tags']['filter']
    }
    refined_boundary_model.contents = input_json['contents']
    refined_boundary_model.meta_info['dtu_configuration'] = \
        input_json['dtu_configuration']
    refined_boundary_model.meta_info['dtu_configuration_maxdiff'] = \
        input_json['dtu_configuration_maxdiff']
    for item in ['function_evaluations', 'global_residual', 'maxDTUoffset',
                 'numresolution', 'parmodel', 'tolerance']:
        refined_boundary_model.meta_info[item] = input_json['meta_info'][item]
    refined_boundary_model.meta_info['origin']['bounddict'] = \

# Path: emirdrp/products.py
# class RefinedBoundaryModelParam(numina.types.structured.BaseStructuredCalibration):
#     """Refined parameters of MOS model
#     """
#     def __init__(self, instrument='unknown'):
#         super(RefinedBoundaryModelParam, self).__init__(instrument)
#         self.tags = {
#             'grism': "unknown",
#             'filter': "unknown"
#         }
#         self.contents = []
# 
#     def __getstate__(self):
#         state = super(RefinedBoundaryModelParam, self).__getstate__()
#         if six.PY2:
#             state['contents'] = copy.copy(self.contents)
#         else:
#             state['contents'] = self.contents.copy()
#         return state
# 
#     def __setstate__(self, state):
#         super(RefinedBoundaryModelParam, self).__setstate__(state)
#         if six.PY2:
#             self.contents = copy.copy(state['contents'])
#         else:
#             self.contents = state['contents'].copy()
# 
#     def tag_names(self):
#         return ['grism', 'filter']


# Path: emirdrp/tools/convert_refined_multislit_bound_param.py
import argparse
import json
import sys
import numina.types.qc
from numina.tools.arg_file_is_new import arg_file_is_new
from numina.tools.check_setstate_getstate import check_setstate_getstate
from emirdrp.products import RefinedBoundaryModelParam


    # optional arguments
    parser.add_argument("--echo",
                        help="Display full command line",
                        action="store_true")
    args = parser.parse_args(args)

    if args.echo:
        print('\033[1m\033[31m% ' + ' '.join(sys.argv) + '\033[0m\n')

    # ---

    # read input JSON file
    input_json = json.loads(open(args.input_json.name).read())

    # generate object of type RefinedBoundaryModelParam from input JSON file
    refined_boundary_model = RefinedBoundaryModelParam(instrument='EMIR')
    refined_boundary_model.tags = {
        'grism': input_json['tags']['grism'],
        'filter': input_json['tags']['filter']
    }
    refined_boundary_model.contents = input_json['contents']
    refined_boundary_model.meta_info['dtu_configuration'] = \
        input_json['dtu_configuration']
    refined_boundary_model.meta_info['dtu_configuration_maxdiff'] = \
        input_json['dtu_configuration_maxdiff']
    for item in ['function_evaluations', 'global_residual', 'maxDTUoffset',
                 'numresolution', 'parmodel', 'tolerance']:
        refined_boundary_model.meta_info[item] = input_json['meta_info'][item]
    refined_boundary_model.meta_info['origin']['bounddict'] = \

        'uuid:' + input_json['meta_info']['origin']['bounddict_uuid']