# $Id: p4.md,v 1.8 2007-02-06 04:28:08 jhoblitt Exp $

#
# We have at least 3 different run types
# a) single epoch differing
# b) magic run operates on "complete" exposures
# c) multiple epoch differing/stacking operations
#

# define a new p4run for a single skycell
p4aRun METADATA
    p4a_id      S32         0       # Primary Key AUTO_INCREMENT
    state       STR         64      # Key
#    mode        STR         64      # Key
    workdir     STR         255
    magic       BOOL        f       # Primary Key
END

# the list of imfiles in our skycell keyed against phase 3
p4aInputExp METADATA
    p4a_id      S32         0       # Primary Key
    exp_tag     STR         64      # Primary Key
    p3_version  S32         0       # Primary Key
# if magic is T then look for the exp_tag in the magic output tables
END

p4aScfile METADATA
    p4a_id      S32         0       # Primary Key
    skycell_id  STR         64      # Primary Key
    tess_id     STR         64      # Primary Key
    exp_tag     STR         64      # Primary Key
    p3_version  S32         0       # Primary Key
    uri         STR         255
    bg          F64         0.0
    bg_mean_stdev   F64     0.0
END

p4bRun METADATA
    p4b_id      S32         0       # Primary Key AUTO_INCREMENT
    state       STR         64      # Key
#    mode        STR         64      # Key
    workdir     STR         255
    magic       BOOL        f       # Primary Key
END

# only ever 2 per run
p4bInputScfile METADATA
    p4b_id      S32         0       # Primary Key
    skycell_id  STR         64      # Primary Key
    tess_id     STR         64      # Primary Key
    exp_tag     STR         64      # Primary Key
    p3_version  S32         0       # Primary Key
# either a input or a template
    kind        STR         64      # Key 
END

p4bDiffScfile METADATA
    p4b_id      S32         0       # Primary Key
    skycell_id  STR         64      # Primary Key
    tess_id     STR         64      # Primary Key
    exp_tag     STR         64      # Primary Key
    p3_version  S32         0       # Primary Key
    uri         STR         255
    bg          F64         0.0
    bg_mean_stdev   F64     0.0
END

# define a new p4run for a single skycell
p4cRun METADATA
    p4c_id      S32         0       # Primary Key AUTO_INCREMENT
    state       STR         64      # Key
#    mode        STR         64      # Key
    workdir     STR         255
    magic       BOOL        f       # Primary Key
END

# the list of imfiles in our skycell keyed against phase 3
p4cInputExp METADATA
    p4c_id      S32         0       # Primary Key
    exp_tag     STR         64      # Primary Key
    p3_version  S32         0       # Primary Key
END

# output from magic
p4MagicMaskImfile METADATA
    p4c_id       S32         0       # Primary Key
    exp_tag     STR         64      # Primary Key
    p3_version  S32         0       # Primary Key
# class is not yet consistently carried through pXtools
#    class       STR         64      # Primary Key
    class_id    STR         64      # Primary Key
    uri         STR         255
END

# output from magic
# p4MagicMaskImfile METADATA
#     p4_id       S32         0       # Primary Key
#     exp_tag     STR         64      # Primary Key
#     p3_version  S32         0       # Primary Key
# # class is not yet consistently carried through pXtools
# #    class       STR         64      # Primary Key
#     class_id    STR         64      # Primary Key
#     uri         STR         255
# END
# 
# # the list of imfiles in our skycell keyed against phase 3
# p4InputImfile  METADATA
#     p4_id       S32         0       # Primary Key
#     skycell_id  STR         64      # Primary Key
#     tess_id     STR         64      # Primary Key
#     exp_tag     STR         64      # Primary Key
#     p3_version  S32         0       # Primary Key
# # class is not yet consistently carried through pXtools
# #    class       STR         64      # Primary Key
#     class_id    STR         64      # Primary Key
# # either a input or a template
#     kind        STR         64      # Key 
# END
# 
# 
# # one diff image per input to the current stack
# # XXX how will diff against the static sky be handled?
# p4DiffImfile METADATA
#     p4_id       S32         0       # Primary Key
#     skycell_id  STR         64      # Primary Key
#     tess_id     STR         64      # Primary Key
#     exp_tag     STR         64      # Primary Key
#     p3_version  S32         0       # Primary Key
# # class is not yet consistently carried through pXtools
# #    class       STR         64      # Primary Key
#     class_id    STR         64      # Primary Key
#     uri         STR         255
#     bg          F64         0.0
#     bg_mean_stdev   F64     0.0
# END
# 
# p4StackedImfile METADATA
#     p4_id       S32         0       # Primary Key
#     skycell_id  STR         64      # Primary Key
#     tess_id     STR         64      # Primary Key
#     exp_tag     STR         64      # Primary Key
#     p3_version  S32         0       # Primary Key
# # class is not yet consistently carried through pXtools
# #    class       STR         64      # Primary Key
#     class_id    STR         64      # Primary Key
#     uri         STR         255
#     bg          F64         0.0
#     bg_mean_stdev   F64     0.0
# END
# 
# # output from magic
# p4MagicMaskImfile METADATA
#     p4_id       S32         0       # Primary Key
#     exp_tag     STR         64      # Primary Key
#     p3_version  S32         0       # Primary Key
# # class is not yet consistently carried through pXtools
# #    class       STR         64      # Primary Key
#     class_id    STR         64      # Primary Key
#     uri         STR         255
# END
