wiki:drmsCheckTriggers
Last modified 6 years ago Last modified on 02/11/14 10:45:06

Checking Triggers

If a site is subscribed to a data series, then it will be notified when there are new storage unit numbers for that series. It is then up to the site to do something about it, that is, to put the storage unit numbers on the queue to get them processed.

To illustrate :

The following SUMS database queries will list all the series tables for aia and hmi :

\d aia.*
\d hmi.*

Note that one of the hmi series is called "hmi.v_avg120", so we can describe that :

\d hmi.v_avg120

Which, among other things, shows :

Triggers:
    hmi_v_avg120_trg AFTER INSERT ON hmi.v_avg120 FOR EACH ROW EXECUTE PROCEDURE hmi_v_avg120_fc()

So the trigger hmi_v_avg120_trg will run the procedure hmi_v_avg120_fc() every time a row is inserted in hmi.v_avg120. To see the procedure :

\df+ hmi_v_avg120_fc()

Which shows the source for the procedure - it adds the sunum to the queue :

BEGIN
 IF (TG_OP='INSERT' AND new.sunum > 0) THEN
  INSERT INTO sunum_queue (sunum,recnum,series_name) VALUES (new.sunum,new.recnum,'hmi.V_avg120');
 END IF;
 RETURN NEW;
END

Note that this still does not get the data on disk - but your local DRMS/SUMS database now has knowledge that the data exists offsite. Given that, the JMD will be able to download it. Triggers and update functions follow the naming convention :

(instrument)_(series)_trg
(instrument)_(series)_fc

To identify triggers for automatically downloading data (writes records into sunum_queue), the convention is :

        trig_update_vso_(shadow table name)

Procedures that maintain the VSO shadow table :

        proc_update_vso_(shadow table name)

Some functions that mention 'dynamical'. This arises because JSOC store their dates as seconds since an epoch in 1968. The functions have the tables of leap seconds so we can convert to unixtime (technically, it forces conversion to the database internal date type). This facilitates queries like :

select (whatever) from aia.lev1 where t_rec_index between dynamical('YYYY-MM-DD') and dynamical('YYYY-MM-DD')
select dynamical_to_unix(date__obs) from aia.lev1 where recnum in ( ... )

These queries may take time, as the tables are big and for the most part, unindexed.