Beispiel #1
0
def _add_basic_metadata(cr, creator):
    """Add CREATOR and DATE keywords to the crate.

    Parameters
    ----------
    cr : Crate
        The crate to add the keywords to.
    creator : str
        The value of the CREATOR keyword.

    Notes
    -----
    The current time is used for the DATE keyword, using
    the FITS-approved format (YYYY-MM-DDTHH:MM:SS). There is
    no attempt to convert the timezone to UTC.
    """

    key1 = pycrates.CrateKey()
    key1.name = "CREATOR"
    key1.value = creator
    key1.desc = "tool that created this output"
    cr.add_key(key1)

    key2 = pycrates.CrateKey()
    key2.name = "DATE"
    key2.value = time.strftime(_fits_time_fmt)
    key2.desc = "Date and time of file creation"
    cr.add_key(key2)
Beispiel #2
0
 def create_key(kname, kval, desc=None):
     store[kname] = crates.CrateKey()
     store[kname].name = kname
     if desc != None:
         store[kname].desc = desc
     if 1 != store[kname].load(kval):
         raise RuntimeError, "Unable to set key %s to %g" % (name, kval)
     if 1 != crates.add_key(cr, store[kname]):
         raise RuntimeError, "Unable to add key %s to Crates." % kname
Beispiel #3
0
def write_key(crate, name, value, comment, units=""):
    """
    Wrapper around crate key creation. Borrowed from srcflux
    """
    kw = pycrates.CrateKey()
    kw.name = name
    kw.value = value
    kw.desc = comment
    kw.unit = units
    crate.add_key(kw)
Beispiel #4
0
def _set_key(crate, name, val, fix_type=False, dtype=str):
    """
    checked for new crates
    """
    key = pycrates.CrateKey()
    key.name = str(name).strip().upper()

    if fix_type:
        val = dtype(val)

    key.value = val
    pycrates.add_key(crate, key)