IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ticket #119: metadata.txt

File metadata.txt, 4.6 KB (added by eugene, 22 years ago)

response to question

Line 
1
2The idea of the psMetadata structure is to enable two competing needs
3of the metadata system. The purpose of the psHash in psMetadata
4is to allow quick access to the string-based keys. The purpose of the
5psList in psMetadata is to maintain a specific order of key/value
6pairs. Partly, this is conceived to allows the psMetadata structure
7to carry the data from a FITS header in such a way that the act of
8reading in and writing out a single FITS header does not change the
9header.
10
11Some background explanation of FITS headers may help clarify this (and
12may help with the issues in bug #120). A FITS header is an ASCII
13segment which preceeds each data segment in a FITS file. The FITS
14header components have a required sequence for some keywords, and a
15set of rules governing the format. An example of a few lines are:
16
17SIMPLE = T / file does conform to FITS standard
18BLANK = -32768 / Value used for NULL pixels
19DATE-OBS= '2004-06-16' / Observation start date (yyyy-mm-dd)
20COMMENT ---------------- DATA BLOCK ---------------------------------
21COMMENT --------------- PARAMETERS FOR SUPRIME_CAM ------------------
22EXPTIME = 1.05 / exposure time for image
23COMMENT ---------------- FOO ----------------------------------------
24
25the keys in FITS headers are always <= 8 upper-case characters, and
26are usually followed by the = sign (the exception are the comment type
27of keys, which have somewhat different rules in general). The key is
28followed (after the =) by the value, followed in turn by an optional
29comment, separated by ' / '. The data values may be integers, floats,
30strings, and booleans (I note that we don't have boolean types in the
31psMetadataType enum, do we?). Keep in mind that the CFITSIO tools
32provide the mechanisms to read in the FITS header blocks correctly
33from a file and to extract the key/value/comments with correct
34interpretation of the formats.
35
36If we require the ability to reconstruct the original order of the
37metadata items in a FITS header (and we do require this), then I don't
38think we can drop the psList.
39
40 However, in looking at the needs, it seems like we may not have
41defined the interaction between the hash and the ITEM_SET list quite
42right. For the hash, I claim we want only one entry per hash key.
43Unique items are no problem, the bucket.data just points to the
44corresponding psMetadataItem entry (and both have the same value for
45'key'). For the non-unique entries, we can't have multiple hash
46entries with the same name. Also, we don't care about getting to a
47specific non-unique entry fast by the hash. Instead, there should be
48a single hash entry for each non-unique key which points at a
49psMetadataItem container with a type of 'ITEM_SET'. the list in this
50set would then point at the collection of all non-unique entries. On
51the other side, the psList entries should each point at the individual
52psMetadataItem entries, whether unique or not. I have drawn a picture
53to illustrate this. (attached).
54
55If I want add a psMetadataItem, I should do the following things:
56
57look for the key in the psHash.
58
59 if it exists, does it point to an entry with type = ITEM_SET?
60
61 If YES, I can add it to the end of that psList (ie, being a little
62 sloppy, metadata->hash->bucket->data->items) as well as to the end
63 of the psMetadata list (metadata->list).
64
65 If NO, this is an error (attempt to repeat a UNIQUE entry).
66
67 if such an entry does not exist, add it to metadata->hash and
68 metadata->list.
69
70 (note that this still allows me to add a psMetadataItem of type
71 ITEM_SET which should have a NULL data value. Also note that if it
72 should be an error to attempt to add a psMetadataItem of type
73 ITEM_SET which already exists).
74
75To delete a unique entry by index, I can get to it from
76metadata->list, which gets me a unique psMetadataItem, delete the
77entry from the list, and then also delete the entry with that name
78from the metadata->hash.
79
80To delete a unique entry by name is also trivial: I get to it from the
81metadata->hash, then I need to find the entry in metadata->list with
82the same ID (not fast, requires looping over almost all entries). To
83delete a n
84
85To delete a non-unique entry, the SDRS says you delete all non-unique
86entries (not sure I agree with this!). To do this by index, I would
87get to the item from metadata->list. Then I would get the entry point
88from metadata->hash with the same name and delete everything in that
89container.
90
91To delete a non-unique entry by name, you need to get to the
92containing entry, then loop over the metadata->list and delete all
93entries by their ID, then delete the container in metadata->hash.
94
95
96