--   dcmpToCMF = {'Xpos': 'X_PSF',
--                'Ypos': 'Y_PSF',
--                'M': 'PSF_INST_MAG',
--                'dM': 'PSF_INST_MAG_SIG',
--                'flux': 'PSF_INST_FLUX',
--                'dflux': 'PSF_INST_FLUX_SIG',
--                'type': 'PADDING',
--                'peakflux': 'PEAK_FLUX_AS_MAG',
--                'sigx': 'MOMENTS_XX',
--                'sigxy': 'MOMENTS_XY',
--                'sigy': 'MOMENTS_YY',
--                'sky': 'SKY',
--                'chisqr': 'PSF_CHISQ',
--                'class': 'DIFF_R_P',
--                'FWHM1': 'PSF_MAJOR',
--                'FWHM2': 'PSF_MINOR',
--                'FWHM': 'DIFF_SN_P',
--                'angle': 'POSANGLE',
--                'extendedness': 'EXT_NSIGMA',
--                'flag': 'FLAGS',
--                'mask': 'FLAGS2',
--                'Nmask': 'N_FRAMES',
--                'RA': 'RA_PSF',
--                'Dec': 'DEC_PSF',
--                'pixchk_Npos': 'DIFF_NPOS',
--                'pixchk_Nneg': 'PSF_NDOF',
--                'pixchk_Nmask': 'PSF_NPIX',
--                'pixchk_Ntot': 'DIFF_R_M',
--                'pixchk_Fpos': 'DIFF_FRATIO',
--                'pixchk_Fneg': 'DIFF_NRATIO_ALL'}

-- DISASTER!! I've allocated the same column (PADDING) twice.  NEED TO FIX!!!!
--                'type': 'PADDING',
--                'pixchk_Ntot': 'PADDING',
create or replace view tcs_v_pp_transient_objects as
select 
`ipp_idet`,
`x_psf` as `Xpos`,
`y_psf` as `Ypos`,
`ra_psf` as `RA`,
`dec_psf` as `Dec`,
`posangle` as `angle`,
`psf_inst_mag` as `M`,
`psf_inst_mag_sig` as `dM`,
`peak_flux_as_mag` as `peakflux`,
`sky` as `sky`,
`psf_chisq` as `chisqr`,
`ext_nsigma` as `extendedness`,
`psf_major` as `FWHM1`,
`psf_minor` as `FWHM2`,
`psf_ndof` as `pixchk_Nneg`,
`psf_npix` as `pixchk_Nmask`,
`moments_xx` as `sigx`,
`moments_xy` as `sigxy`,
`moments_yy` as `sigy`,
`flags` as `flag`,
`n_frames` as `Nmask`,
`padding` as `type`,
`psf_inst_flux` as `flux`,
`psf_inst_flux_sig`as `dflux`,
`diff_npos` as `pixchk_Npos`,
`diff_fratio` as `pixchk_Fpos`,
`diff_nratio_all` as `pixchk_Fneg`,
`diff_r_m` as `pixchk_Ntot`,
`diff_r_p` as `class`,
`diff_sn_p` as `FWHM`,
`flags2` as `mask`,
`local_designation`,
`local_comments`,
`htm20ID`,
`htm16ID`,
`cx`,
`cy`,
`cz`,
`id`,
`tcs_cmf_metadata_id`,
`tcs_images_id`,
`date_inserted`,
`date_modified`,
`object_classification`,
`followup_priority`,
`external_reference_id`,
`followup_id`,
`postage_stamp_request_id`,
`image_group_id`,
`detection_list_id`,
`followup_flag_date`,
`survey_field`,
`followup_counter`,
`ps1_designation`,
`other_designation`,
`confidence_factor`,
`quality_threshold_pass`,
`locally_calculated_mag`,
`zoo_request_id`,
`current_trend`,
`observation_status`,
`deprecated`,
`tti_pair`,
`processing_flags`,
`updated_by`,
`classification_confidence`,
`classification_type`
from tcs_transient_objects;

create or replace view tcs_v_pp_transient_reobservations as
select
`ipp_idet`,
`x_psf` as `Xpos`,
`y_psf` as `Ypos`,
`ra_psf` as `RA`,
`dec_psf` as `Dec`,
`posangle` as `angle`,
`psf_inst_mag` as `M`,
`psf_inst_mag_sig` as `dM`,
`peak_flux_as_mag` as `peakflux`,
`sky` as `sky`,
`psf_chisq` as `chisqr`,
`ext_nsigma` as `extendedness`,
`psf_major` as `FWHM1`,
`psf_minor` as `FWHM2`,
`psf_ndof` as `pixchk_Nneg`,
`psf_npix` as `pixchk_Nmask`,
`moments_xx` as `sigx`,
`moments_xy` as `sigxy`,
`moments_yy` as `sigy`,
`flags` as `flag`,
`n_frames` as `Nmask`,
`padding` as `type`,
`psf_inst_flux` as `flux`,
`psf_inst_flux_sig`as `dflux`,
`diff_npos` as `pixchk_Npos`,
`diff_fratio` as `pixchk_Fpos`,
`diff_nratio_all` as `pixchk_Fneg`,
`diff_r_m` as `pixchk_Ntot`,
`diff_r_p` as `class`,
`diff_sn_p` as `FWHM`,
`flags2` as `mask`,
`htm20ID`,
`htm16ID`,
`cx`,
`cy`,
`cz`,
`id`,
`tcs_cmf_metadata_id`,
`tcs_images_id`,
`transient_object_id`,
`date_inserted`,
`date_modified`,
`local_comments`,
`postage_stamp_request_id`,
`image_group_id`,
`quality_threshold_pass`,
`locally_calculated_mag`,
`deprecated`,
`confidence_factor`
from tcs_transient_reobservations;
