# 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
def main(args=None):
    # parse command-line options
    parser = argparse.ArgumentParser(
        description='description: convert JSON file with refined multislit '
                    'parameters to new JSON format'
    )

    # required arguments
    parser.add_argument("input_json",
                        help="Input JSON with refined boundary parameters",
                        type=argparse.FileType('rt'))
    parser.add_argument("output_json",
                        help="Output JSON with fitted boundary parameters",
                        type=lambda x: arg_file_is_new(parser, x, mode='wt'))

    # 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

# 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

def main(args=None):
    # parse command-line options
    parser = argparse.ArgumentParser(
        description='description: convert JSON file with refined multislit '
                    'parameters to new JSON format'
    )

    # required arguments
    parser.add_argument("input_json",
                        help="Input JSON with refined boundary parameters",
                        type=argparse.FileType('rt'))
    parser.add_argument("output_json",
                        help="Output JSON with fitted boundary parameters",
                        type=lambda x: arg_file_is_new(parser, x, mode='wt'))

    # 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')