{"action":"created","issue":{"url":"https://api.github.com/repos/astroufsc/chimera/issues/97","labels_url":"https://api.github.com/repos/astroufsc/chimera/issues/97/labels{/name}","comments_url":"https://api.github.com/repos/astroufsc/chimera/issues/97/comments","events_url":"https://api.github.com/repos/astroufsc/chimera/issues/97/events","html_url":"https://github.com/astroufsc/chimera/pull/97","id":97974924,"number":97,"title":"Custom header keywords trough chimera plugins","user":{"login":"wschoenell","id":1873811,"avatar_url":"https://avatars.githubusercontent.com/u/1873811?v=3","gravatar_id":"","url":"https://api.github.com/users/wschoenell","html_url":"https://github.com/wschoenell","followers_url":"https://api.github.com/users/wschoenell/followers","following_url":"https://api.github.com/users/wschoenell/following{/other_user}","gists_url":"https://api.github.com/users/wschoenell/gists{/gist_id}","starred_url":"https://api.github.com/users/wschoenell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wschoenell/subscriptions","organizations_url":"https://api.github.com/users/wschoenell/orgs","repos_url":"https://api.github.com/users/wschoenell/repos","events_url":"https://api.github.com/users/wschoenell/events{/privacy}","received_events_url":"https://api.github.com/users/wschoenell/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-07-29T16:28:23Z","updated_at":"2015-08-06T20:06:42Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/astroufsc/chimera/pulls/97","html_url":"https://github.com/astroufsc/chimera/pull/97","diff_url":"https://github.com/astroufsc/chimera/pull/97.diff","patch_url":"https://github.com/astroufsc/chimera/pull/97.patch"},"body":"This PR fixes #50. It implements a way to have flexible headers for each observatory by the means of controller plugins. The changes needed on chimera code (and done here) are:\r\n\r\n* Move the metadata information of the camera instrument from `_saveImage()` to a new  method `getMetadata()` to be consistent with the other instruments structure.\r\n\r\n* Add a new variable to the `ChimeraObject` class named `__metadataOverrideMethod__`. This variable, if different of `None`, will store the location of the object which must contain a `getMetadata()` method and will replace the instrument's (and site) original  `getMetadata()` method.\r\n\r\n* Add two new methods on `ChimeraObject`: `setMetadataMethod()` and `getMetadataOverride()`. The first one is used if one wants to override the default metadata method of a instrument by another object on chimera's namespace. The usage is something like:\r\n\r\n```python\r\nmyInstrument = getManager().getProxy('/Instrument/name', lazy=True)\r\nmyInstrument.setMetadataMethod('/HeaderOverrider/name')\r\n```\r\n\r\nThe second one should be called on all `getMetadata()` methods before the instrument's  metadata itself being written. The call would be, for example:\r\n\r\n```python\r\ndef getMetadata(self, request):\r\n\t# Check first if there is metadata from an metadata override method.\r\n\tmd = self.getMetadataOverride(request)\r\n\tif md is not None:\r\n\t\treturn md\r\n\t# If not, just go on with the instrument's default metadata.\r\n\treturn [(... instrument s metadata here ...)]\r\n```\r\n\r\nOther minor changes:\r\n\r\n* Corrected minor typos and PEP8 on `fakecamera.py` and `site.py`\r\n\r\n* Added `CHECKSUM` and `DATASUM` header keywords to all files saved by chimera.\r\n\r\n* Moved extras to a class variable and created a method to extract it. I think that extras option on `_saveImage()` could go away sometime, but now I left this way for compatibility with the existent camera drivers. Maybe when doing the wcs move to the `Image` class (#93)\r\n\r\nAn template of a controller that does modifications on a fits header can be seen here: https://www.github.com/astroufsc/chimera-headers\r\n\r\nWhen running chimera with that controller configured for all the fake instruments, one haves a fits header like the below. All headers with `Custom. ` in the beginning of the comment where changed by that controller. The others are static and cannot be changed.\r\n\r\n```\r\nSIMPLE  =                    T / conforms to FITS standard                      \r\nBITPIX  =                   16 / array data type                                \r\nNAXIS   =                    2 / number of array dimensions                     \r\nNAXIS1  =                  512                                                  \r\nNAXIS2  =                  512                                                  \r\nEXTEND  =                    T                                                  \r\nBZERO   =                32768                                                  \r\nDATE    = '2015-07-29T15:15:22.233742' / date of file creation                  \r\nAUTHOR  = 'chimera '           / Observatory Automation System                  \r\nOBJECT  = 'object  '           / name of observed object                        \r\nSITE    = 'T80S    '           / Custom. Site name (in config)                  \r\nLATITUDE= '-70:48:20.480'      / Custom. Site latitude                          \r\nLONGITUD= '-30:10:04.310'      / Custom. Site longitude                         \r\nALTITUDE= '2187    '           / Custom. Site altitude                          \r\nDATE-OBS= '2015-07-29T15:15:21.082973' / Custom. Date exposure started          \r\nEXPTIME =                  1.0 / Custom. exposure time in seconds               \r\nIMAGETYP= 'object  '           / Custom. Image type                             \r\nSHUTTER = 'OPEN    '           / Custom. Requested shutter state                \r\nINSTRUME= 'Fake Cameras Inc.'  / Custom. Name of instrument                     \r\nCCD     = 'Fake CCDs Inc.'     / Custom. CCD Model                              \r\nCCD_DIMX=                  512 / Custom. CCD X Dimension Size                   \r\nCCD_DIMY=                  512 / Custom. CCD Y Dimension Size                   \r\nCCDPXSZX=                    9 / Custom. CCD X Pixel Size [micrometer]          \r\nCCDPXSZY=                    9 / Custom. CCD Y Pixel Size [micrometer]          \r\nCRPIX1  =                  255 / Custom. coordinate system reference pixel      \r\nCRPIX2  =                  255 / Custom. coordinate system reference pixel      \r\nCD1_1   = 0.000515662015617741 / Custom. transformation matrix element (1,1)    \r\nCD1_2   =                 -0.0 / Custom. transformation matrix element (1,2)    \r\nCD2_1   =                  0.0 / Custom. transformation matrix element (2,1)    \r\nCD2_2   = 0.000515662015617741 / Custom. transformation matrix element (2,2)    \r\nDOME_MDL= 'Fake Domes Inc.'    / Custom. Dome Model                             \r\nDOME_TYP= 'Classic '           / Custom. Dome Type                              \r\nDOME_TRK= 'Track   '           / Custom. Dome Tracking/Standing                 \r\nDOME_SLT= 'Closed  '           / Custom. Dome slit status                       \r\nFOCUSER = 'Fake Focus v.1'     / Custom. Focuser Model.                         \r\nFOCUS   =                 3500 / Custom. Focuser position used for this observat\r\nTELESCOP= 'Fake Telescopes Inc.' / Custom. Telescope Model                      \r\nOPTICS  = 'Newtonian'          / Custom. Telescope Optics Type                  \r\nMOUNT   = 'Mount type Inc.'    / Custom. Telescope Mount Type                   \r\nAPERTURE=                100.0 / Custom. Telescope aperture size [mm]           \r\nF_LENGTH=               1000.0 / Custom. Telescope focal length [mm]            \r\nF_REDUCT=                  1.0 / Custom. Telescope focal reduction              \r\nRA      = '08:29:03.740'       / Custom. Right ascension of the observed object \r\nDEC     = '-03:00:00.000'      / Custom. Declination of the observed object     \r\nEQUINOX =               2000.0 / Custom. coordinate epoch                       \r\nALT     = '+21:09:51.623'      / Custom. Altitude of the observed object        \r\nAZ      = '+340:17:31.456'     / Custom. Azimuth of the observed object         \r\nWCSAXES =                    2 / Custom. wcs dimensionality                     \r\nRADESYS = 'ICRS    '           / Custom. frame of reference                     \r\nCRVAL1  =    127.2655845654916 / Custom. coordinate system value at reference pi\r\nCRVAL2  =   -3.000000000000017 / Custom. coordinate system value at reference pi\r\nCTYPE1  = 'RA---TAN'           / Custom. name of the coordinate axis            \r\nCTYPE2  = 'DEC--TAN'           / Custom. name of the coordinate axis            \r\nCUNIT1  = 'deg     '           / Custom. units of coordinate value              \r\nCUNIT2  = 'deg     '           / Custom. units of coordinate value              \r\nCHECKSUM= 'U8a3U5Z3U5a3U5Y3'   / HDU checksum updated 2015-07-29T17:15:23       \r\nDATASUM = '192873200'          / data unit checksum updated 2015-07-29T17:15:23 \r\nCCD-TEMP=    20.30499427111227 / Custom. CCD Temperature at Exposure Start [deg.\r\nCHM_ID  = '0ab51b1a2599217c3cfc2e650621477d2c'                                  \r\nEND                                                                             \r\n```"},"comment":{"url":"https://api.github.com/repos/astroufsc/chimera/issues/comments/128489534","html_url":"https://github.com/astroufsc/chimera/pull/97#issuecomment-128489534","issue_url":"https://api.github.com/repos/astroufsc/chimera/issues/97","id":128489534,"user":{"login":"wschoenell","id":1873811,"avatar_url":"https://avatars.githubusercontent.com/u/1873811?v=3","gravatar_id":"","url":"https://api.github.com/users/wschoenell","html_url":"https://github.com/wschoenell","followers_url":"https://api.github.com/users/wschoenell/followers","following_url":"https://api.github.com/users/wschoenell/following{/other_user}","gists_url":"https://api.github.com/users/wschoenell/gists{/gist_id}","starred_url":"https://api.github.com/users/wschoenell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wschoenell/subscriptions","organizations_url":"https://api.github.com/users/wschoenell/orgs","repos_url":"https://api.github.com/users/wschoenell/repos","events_url":"https://api.github.com/users/wschoenell/events{/privacy}","received_events_url":"https://api.github.com/users/wschoenell/received_events","type":"User","site_admin":false},"created_at":"2015-08-06T20:06:42Z","updated_at":"2015-08-06T20:06:42Z","body":"On Thu, Aug 6, 2015, 21:17 Paulo Henrique Silva <notifications@github.com>\nwrote:\n\nTo be compliant with pipeline software we need headers, in any way, even\nmanually if someone would like this task.\n\nAll you want is to get all headers from everything possibly running that\naffects that exposure, right!?\n\n\nYes and no. What we want is to have headers of everything but also to have\nthem on the standard which meets the observatory/pipeline software\nstandards. If, for example, the observatory standard is `EXP-TIME` for\nexposure time and the chimera standard is `EXPTIME`, things will not work.\nOf course this is a silly example. I can give you more realistic ones.\n\n\nThis Header instrument as it is now will cause huge performance issues by\nmoving the getMetadata class to its own control. Every call to\nself.instrument.X is a remote call now instead of a local one if the\nresponsible for it was the original instrument.\n\n\nMaybe I did not got point but I don't see how this could interfere on the\nperformance of chimera. We have been using many remote calls all over the\ncode. Every call to `self.instrument.getMetadata()` which is only for\nmetadata purposes will be a to\n`getManager().getProxy(self.__metadataOverrideMethod__).getMetadata(request)`\nif there is an metadata controller. This is the way that it is done now is\ndoing a remote call likewise the call over an controller... No?\n\nhttps://github.com/astroufsc/chimera/blob/3056296fc951d09a3765b06499a9c8a001363129/src/chimera/controllers/imageserver/imagerequest.py#L147-L158\n\n\nI think Site is the one to gather all info about what instruments compose\nan observatory or part of it, if you take an image using a camera, it asks\nthe Header controller to get its headers, Header controller goes on the\nsite containing that camera (it must be only unique) and iterate over all\ninstruments listed there asking getMetadata on that instrument (which knows\nhow to compute it locally). That seems sane in terms of performance and in\nterms of coupling.\n\nPS: Site is weird and maybe a misnomer, in this context we can think of\nsite as a group of instruments that make sense together.\n\n\nI don't really see how to do this without changing all the way how chimera\ngets headers from the instruments.\n\n\n—\nReply to this email directly or view it on GitHub\n<https://github.com/astroufsc/chimera/pull/97#issuecomment-128478856>.<img\nsrc=\"\nhttps://ci4.googleusercontent.com/proxy/zHxB5hP5kJWclZO5wMlf67Px3befD42ccwXw_7rqLwyVE8vr7Nuatnv9u1jTJyF3nZJIwpa-soe9DczxwiDWI3ZYGZoQdGkrZFcruzg5PWbhSsBv9LtQSWlUEY2MdmnOEKTUB7mNsZoeI66Zra5xJU736AxcsQ=s0-d-e1-ft#https://github.com/notifications/beacon/AByXk27T3_Z0IkwI-rZo5J_AJfvv9WHOks5ok6pPgaJpZM4FiHmR.gif\n\">\n"}}