Esempio n. 1
0
    plan = args.plan
    observatory = args.observatory

    if loc == 'local':
        targetdb.database.connect_from_parameters(user='******',
                                                  host='localhost',
                                                  port=7502)
    else:
        targetdb.database.connect_from_parameters(
            user='******', host='operations.sdss.utah.edu', port=5432)

    valid_data = fits.open(
        ('/uufs/chpc.utah.edu/common/home/sdss50/sdsswork/'
         'sandbox/mugatu/rs_plan_validations/{plan}/'
         'rs_{plan}_{obs}_design_validation_results.fits'.format(
             plan=plan, obs=observatory)))[1].data
    for valid in valid_data:
        fieldid = int(valid['file_name'].split('-')[-1])
        exp = int(valid['exp'])
        design = (targetdb.Design.select(targetdb.Design.design_id).join(
            targetdb.Field).where((targetdb.Field.field_id == fieldid)
                                  & (targetdb.Design.exposure == exp)))
        try:
            design_id = design[0].design_id
        except IndexError:
            print('No Design for field %d, exp %d' % (fieldid, exp))
            break
        make_desigmmode_results_targetdb(design_id=design_id,
                                         design_pass=True,
                                         design_valid_file_row=valid)
Esempio n. 2
0
             desmode_label=desmode_label,
             design_ids=design_inst['carton_to_target_pk'],
             robotID=roboIDs,
             holeID=holeIDs,
             obsWavelength=design_inst['fiberType'],
             carton=design_inst['carton'],
             observatory=obs_inst[field_replace.observatory.label],
             targetdb_ver=None,
             instr_pks=instr_pks,
             cart_pks=None,
             fiber_pks=fiber_pks[field_replace.observatory.label],
             idtype='carton_to_target',
             return_design_id=True)
         make_desigmmode_results_targetdb(
             design_id=design_id,
             design_pass=True,
             design_valid_file_row=valid_data[i],
             design_status=design_status_bitmask(replacement_design=True))
 elif n_exp == 1:
     for i in range(n_exp_expc):
         # repeat same design so always use only index
         roboIDs = design['robotID']
         holeIDs = design['holeID']
         desmode_label = desmode_labels[0]
         # write exposure to targetdb
         design_id = make_design_assignments_targetdb(
             plan=ver_inst,
             fieldid=fieldid_inst,
             exposure=i,
             field_exposure=i,  # safe to assume same for these?
             desmode_label=desmode_label,
    parser.add_argument('-d',
                        '--dir',
                        dest='dir',
                        type=str,
                        help='directory with design validation_files',
                        required=True)

    args = parser.parse_args()
    loc = args.loc
    directory = args.dir

    if loc == 'local':
        targetdb.database.connect_from_parameters(user='******',
                                                  host='localhost',
                                                  port=7502)
    else:
        targetdb.database.connect_from_parameters(
            user='******', host='operations.sdss.utah.edu', port=5432)

    valid_data = fits.open(directory +
                           'design_validation_results.fits')[1].data
    valid_design_ids = fits.open(directory +
                                 'design_ids_for_design_files.fits')[1].data
    for valid in valid_data:
        ind = np.where((valid_design_ids['file_name'] == valid['file_name'])
                       & (valid_design_ids['exp'] == valid['exp']))[0][0]
        make_desigmmode_results_targetdb(
            design_id=valid_design_ids[ind]['design_id'],
            design_pass=True,
            design_valid_file_row=valid)