-- View: kronos.epn_core

DROP VIEW kronos.epn_core;

CREATE OR REPLACE VIEW kronos.epn_core AS 
 SELECT 'granule'::text AS resource_type,
    '1'::text AS dataset_id,
    jouve.index_ AS index,
    cast(jouve.dataproduct_type as text) as dataproduct_type,
    cast(jouve.target_name as text) as target_name,
    cast(jouve.target_class as text) as target_class,
    cast(jouve.time_min as double precision) as time_min,
    cast(jouve.time_max as double precision) as time_max,
    jouve.time_sampling_step_min,
    jouve.time_sampling_step_max,
    NULL::double precision AS time_exp_min,
    NULL::double precision AS time_exp_max,
    NULL::double precision AS spectral_range_min,
    NULL::double precision AS spectral_range_max,
    NULL::double precision AS spectral_sampling_step_min,
    NULL::double precision AS spectral_sampling_step_max,
    NULL::double precision AS spectral_resolution_min,
    NULL::double precision AS spectral_resolution_max,
    jouve.c1min,
    jouve.c1max,
    jouve.c2min,
    jouve.c2max,
    jouve.c3min,
    jouve.c3max,
    jouve.c1_resol_min,
    jouve.c1_resol_max,
    jouve.c2_resol_min,
    jouve.c2_resol_max,
    jouve.c3_resol_min,
    jouve.c3_resol_max,
    cast(jouve.spatial_frame_type as text) as spatial_frame_type,
    NULL::double precision AS incidence_min,
    NULL::double precision AS incidence_max,
    NULL::double precision AS emergence_min,
    NULL::double precision AS emergence_max,
    NULL::double precision AS phase_min,
    NULL::double precision AS phase_max,
    cast(jouve.instrument_host_name as text) as instrument_host_name,
    cast(jouve.instrument_name as text) as instrument_name,
    cast(jouve.measurement_type as text) as measurement_type,
    regexp_replace(jouve.filename::text, '/home/lesidaner/outils_vo/cdf/data'::text, 'http://voparis-srv.obspm.fr/vo/planeto/kronos'::text) AS access_url,
    cast(jouve.access_format as text) as access_format,
    jouve.access_estsize,
    integer '3' AS processing_level,
    'vo paris data centre on behalf of LESIA'::text AS publisher,
    'http://adsabs.harvard.edu/abs/2010Icar..205..559V'::text AS reference,
    'abundance Vertical Profile at Titan with Cassini/CIRS'::text AS service_title,
    'atmosphere'::text AS target_region,
    cast(jouve.instrument_type as text) as instrument_type,
    'UTC'::text AS time_scale
   FROM kronos.jouve
UNION ALL
 SELECT 'dataset'::text AS resource_type,
    '1'::text AS dataset_id,
    1 AS index,
    'ts'::text AS dataproduct_type,
    'Jupiter'::text AS target_name,
    'planet'::text AS target_class,
    cast(min(jouve.time_min) as double precision) as time_min,
    cast(max(jouve.time_max) as double precision) as time_max,
    min(jouve.time_sampling_step_min) AS time_sampling_step_min,
    max(jouve.time_sampling_step_max) AS time_sampling_step_max,
    NULL::double precision AS time_exp_min,
    NULL::double precision AS time_exp_max,
    NULL::double precision AS spectral_range_min,
    NULL::double precision AS spectral_range_max,
    NULL::double precision AS spectral_sampling_step_min,
    NULL::double precision AS spectral_sampling_step_max,
    NULL::double precision AS spectral_resolution_min,
    NULL::double precision AS spectral_resolution_max,
    min(jouve.c1min) AS c1min,
    max(jouve.c1max) AS c1max,
    min(jouve.c2min) AS c2min,
    max(jouve.c2max) AS c2max,
    min(jouve.c3min) AS c3min,
    max(jouve.c3max) AS c3max,
    min(jouve.c1_resol_min) AS c1_resol_min,
    max(jouve.c1_resol_max) AS c1_resol_max,
    min(jouve.c2_resol_min) AS c2_resol_min,
    max(jouve.c2_resol_max) AS c2_resol_max,
    min(jouve.c3_resol_min) AS c3_resol_min,
    max(jouve.c3_resol_max) AS c3_resol_max,
    'spherical'::text AS spatial_frame_type,
    NULL::double precision AS incidence_min,
    NULL::double precision AS incidence_max,
    NULL::double precision AS emergence_min,
    NULL::double precision AS emergence_max,
    NULL::double precision AS phase_min,
    NULL::double precision AS phase_max,
    'Cassini Orbiter'::text AS instrument_host_name,
    'RPWS>Radio and Plasma Waves Science HFR>High Frequency ReceiverInfrared Spectrometer (CIRS)'::text AS instrument_name,
    'phys.density;phys.electron phys.temperature;phys.electron'::text AS measurement_type,
    NULL::text AS access_url,
    'cdf'::text AS access_format,
    NULL::integer AS access_estsize,
    3 AS processing_level,
    'vo paris data centre on behalf of LESIA'::text AS publisher,
    'http://adsabs.harvard.edu/abs/2010Icar..205..559V'::text AS reference,
    'abundance Vertical Profile at Titan with Cassini/CIRS'::text AS service_title,
    'atmsphere'::text AS target_region,
    NULL::text AS instrument_type,
    'UTC'::text AS time_scale
   FROM kronos.jouve;

ALTER TABLE kronos.epn_core
  OWNER TO postgres;
GRANT ALL ON TABLE kronos.epn_core TO postgres;
GRANT ALL ON TABLE kronos.epn_core TO gavoadmin WITH GRANT OPTION;
GRANT ALL ON TABLE kronos.epn_core TO gavo WITH GRANT OPTION;
GRANT ALL ON TABLE kronos.epn_core TO dachsroot WITH GRANT OPTION;

