
drop view dynastvo.epn_core;
CREATE or REPLACE VIEW dynastvo.epn_core AS SELECT 

cast(id_gaia as text) AS granule_uid,  
text 'dynastvo' AS granule_gid,  
cast(id_mpc as text)  AS obs_id,
text 'ci' AS dataproduct_type, 
target_name AS target_name, 
text 'asteroid' AS target_class, 
cast(NULL as double precision) AS time_min,
cast(NULL as double precision) AS time_max,
CAST(NULL AS DOUBLE PRECISION) AS time_sampling_step_min,
CAST(NULL AS DOUBLE PRECISION) AS time_sampling_step_max,
CAST(NULL AS DOUBLE PRECISION) AS time_exp_min,
CAST(NULL AS DOUBLE PRECISION) AS time_exp_max,
CAST(NULL AS DOUBLE PRECISION) AS spectral_range_min,
CAST(NULL AS DOUBLE PRECISION) AS spectral_range_max,
CAST(NULL AS DOUBLE PRECISION) AS spectral_sampling_step_min,
CAST(NULL AS DOUBLE PRECISION) AS spectral_sampling_step_max,
CAST(NULL AS DOUBLE PRECISION) AS spectral_resolution_min,
CAST(NULL AS DOUBLE PRECISION) AS spectral_resolution_max,
CAST(NULL AS DOUBLE PRECISION) AS c1min,
CAST(NULL AS DOUBLE PRECISION) AS c1max,
CAST(NULL AS DOUBLE PRECISION) AS c2min,
CAST(NULL AS DOUBLE PRECISION) AS c2max,
CAST(NULL AS DOUBLE PRECISION) as c3min,
CAST(NULL AS DOUBLE PRECISION) as c3max,
CAST(NULL AS DOUBLE PRECISION) as c1_resol_min,
CAST(NULL AS DOUBLE PRECISION) as c1_resol_max,
CAST(NULL AS DOUBLE PRECISION) as c2_resol_min,
CAST(NULL AS DOUBLE PRECISION) as c2_resol_max,
CAST(NULL AS DOUBLE PRECISION) as c3_resol_min,
CAST(NULL AS DOUBLE PRECISION) as c3_resol_max,
cast(NULL as TEXT) AS spatial_frame_type,
CAST(NULL AS DOUBLE PRECISION) as incidence_min,
CAST(NULL AS DOUBLE PRECISION) as incidence_max,
CAST(NULL AS DOUBLE PRECISION) as emergence_min,
CAST(NULL AS DOUBLE PRECISION) as emergence_max,
CAST(NULL AS DOUBLE PRECISION) as phase_min,
CAST(NULL AS DOUBLE PRECISION) as phase_max,
cast(NULL as TEXT) AS instrument_host_name,
cast(NULL as TEXT) AS instrument_name, 
text 'phys.angSize.smajAxis;src.orbital.smajAxis#src.orbital.eccentricity#src.orbital.node#src.orbital.periastron#src.orbital.meanAnomaly#phys.magAbs' AS measurement_type,
cast(NULL as TEXT) AS access_url,
cast(NULL as TEXT) AS access_format,
cast(NULL as integer) AS access_estsize,
integer '5' AS processing_level,
text 'PADC on behalf of IMCCE' AS publisher,
text 'http://adsabs.harvard.edu/abs/2016DPS....4832902D' AS bib_reference,
text 'dynastvo' AS service_title,
cast(NULL as TEXT) AS target_region,
text  'UTC' AS time_scale,
modification_date as release_date,
modification_date AS creation_date,
modification_date AS modification_date,
CAST(NULL AS spoly) AS s_region,
cast(NULL as TEXT) AS thumbnail_url,

semi_major_axis as semi_major_axis,
eccentricity as eccentricity,
inclination as inclination,
long_asc as long_asc,
arg_perihel as arg_perihel,
mean_anomaly as mean_anomaly,
epoch as epoch,

semi_major_axis_error as semi_major_axis_error,
eccentricity_error as eccentricity_error,
inclination_error as inclination_error,
long_asc_error as long_asc_error,
arg_perihel_error as arg_perihel_error,
mean_anomaly_error as mean_anomaly_error,
moid as moid,
spu as spu,
mag as magnitude,
slope as slope,

-- dynastvo.name.name as target_name,
id_mpc as id_mpc,
id_spk as id_spk,
id_gaia as id_gaia,
alt_target_name as alt_target_name,
covar_mat as covar_mat,
cartesian_x as cartesian_x,
cartesian_y as cartesian_y,
cartesian_z as cartesian_z,
cartesian_vx as cartesian_vx,
cartesian_vy as cartesian_vy,
cartesian_vz as cartesian_vz,
pha as pha,
dynamical_class as dynamical_class,
dynamical_type as dynamical_type,
fit_nb_obs_used as fit_nb_obs_used,
fit_nb_obs_rejected as fit_nb_obs_rejected,
fit_nb_obs_ranging as fit_nb_obs_ranging,
fit_nb_obs_doppler as fit_nb_obs_doppler,
fit_jd_initial as fit_jd_initial,
fit_jd_final as fit_jd_final,
cast(lastdou as text) as lastdou,
rms_obs as rms_obs
FROM dynastvo.vepn_core;






