Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-21320

Add first metric to colorAnalysis

    XMLWordPrintable

    Details

    • Story Points:
      6
    • Epic Link:
    • Sprint:
      DRP F19-4
    • Team:
      Data Release Production

      Description

      Add a first metric in the context of the LSST verification framework to the colorAnalysis.py script in pipe_analysis. The metric is to be uploaded to and tracked by the SQuaSH metrics dashboard. The first metric added will be the width of the stellar locus.

        Attachments

          Issue Links

            Activity

            Hide
            lauren Lauren MacArthur added a comment - - edited

            I have added two metrics called stellar_locus_width_wPerp and stellar_locus_width_xPerp which are computed in the colorAnalysisTask and persisted as a json file (using the hacky method of getting the filename path from a new template defined in obs_subaru here...this is required until these json files are mae properly butler.put() persistable).

            The output json file looks like:

            lauren@lsst-dev01: more /datasets/hsc/repo/rerun/private/lauren/DM-21320/verify/color/tract-9813/colorAnalysis_verify_job.json 
            {"measurements": [{"metric": "pipe_analysis.stellar_locus_width_wPerp", "identifier": "e15a11da94ec4b3eabaab151fe5a5256", "value": 18.519, "unit": "mmag", "blob_refs": []}, {"metric": "pipe_analysis.stellar_locus_width_xPerp", "identifier": "f5db0c5e0d8c426f8798cdf6e1f5d543", "value": 46.081, "unit": "mmag", "blob_refs": []}], "blobs": [], "metrics": [{"name": "pipe_analysis.stellar_locus_width_wPerp", "description": "The rms width of the \"wPerp\" principle color stellar locus: the blue section on the r-i vs g-r plane using PSF fluxes.", "unit": "mmag", "tags": ["colorAnalysisTask", "PSFflux", "photometry", "stellarLocus", "coadd"], "reference": {"doc": "Ivezic, Z. et al. 2004, AN 325, SDSS data management and photometric quality assessment", "page": 586, "url": "https://onlinelibrary.wiley.com/doi/pdf/10.1002/asna.200410285"}}, {"name": "pipe_analysis.stellar_locus_width_xPerp", "description": "The rms width of the \"xPerp\" principle color stellar locus: the red section on the r-i vs g-r plane using PSF fluxes.", "unit": "mmag", "tags": ["colorAnalysisTask", "PSFflux", "photometry", "stellarLocus", "coadd"], "reference": {"doc": "Ivezic, Z. et al. 2004, AN 325, SDSS data management and photometric quality assessment", "page": 586, "url": "https://onlinelibrary.wiley.com/doi/pdf/10.1002/asna.200410285"}}], "specs": [{"name": "pipe_analysis.stellar_locus_width_wPerp.griPSF_wFit", "type": "threshold", "threshold": {"value": 25.0, "unit": "mmag", "operator": "<="}, "metadata_query": {"filter_name": "HSC-G^HSC-R^HSC-I"}, "tags": ["minimum", "gri", "stellar_locus_width"]}, {"name": "pipe_analysis.stellar_locus_width_xPerp.griPSF_xFit", "type": "threshold", "threshold": {"value": 50.0, "unit": "mmag", "operator": "<="}, "metadata_query": {"filter_name": "HSC-G^HSC-R^HSC-I"}, "tags": ["minimum", "gri", "stellar_locus_width"]}], "meta": {"name": "griPSF-xFit", "numberUsedInFit": 5058, "numberTotal": 5070, "mean": 0.122, "median": 1.079, "galacticExtinctionCorrection": "GE applied: Per Object", "camera": "HSC"}}
            

            These metrics have been successfully defined in the SQuaSH sandbox instance following the instructions at https://sqr-019.lsst.io/#Dispatching-verification-jobs-to-SQUASH and the job was successfully dispatched, as seen in this snapshot of the sandbox chronograph (note there are two points: the first was measured on a single patch for testing, the second is the same rerun, but for full tract):

            Show
            lauren Lauren MacArthur added a comment - - edited I have added two metrics called stellar_locus_width_wPerp and stellar_locus_width_xPerp which are computed in the colorAnalysisTask and persisted as a json file (using the hacky method of getting the filename path from a new template defined in obs_subaru here...this is required until these json files are mae properly butler.put() persistable). The output json file looks like: lauren@lsst - dev01: more / datasets / hsc / repo / rerun / private / lauren / DM - 21320 / verify / color / tract - 9813 / colorAnalysis_verify_job.json { "measurements" : [{ "metric" : "pipe_analysis.stellar_locus_width_wPerp" , "identifier" : "e15a11da94ec4b3eabaab151fe5a5256" , "value" : 18.519 , "unit" : "mmag" , "blob_refs" : []}, { "metric" : "pipe_analysis.stellar_locus_width_xPerp" , "identifier" : "f5db0c5e0d8c426f8798cdf6e1f5d543" , "value" : 46.081 , "unit" : "mmag" , "blob_refs" : []}], "blobs" : [], "metrics" : [{ "name" : "pipe_analysis.stellar_locus_width_wPerp" , "description" : "The rms width of the \"wPerp\" principle color stellar locus: the blue section on the r-i vs g-r plane using PSF fluxes." , "unit" : "mmag" , "tags" : [ "colorAnalysisTask" , "PSFflux" , "photometry" , "stellarLocus" , "coadd" ], "reference" : { "doc" : "Ivezic, Z. et al. 2004, AN 325, SDSS data management and photometric quality assessment" , "page" : 586 , "url" : "https://onlinelibrary.wiley.com/doi/pdf/10.1002/asna.200410285" }}, { "name" : "pipe_analysis.stellar_locus_width_xPerp" , "description" : "The rms width of the \"xPerp\" principle color stellar locus: the red section on the r-i vs g-r plane using PSF fluxes." , "unit" : "mmag" , "tags" : [ "colorAnalysisTask" , "PSFflux" , "photometry" , "stellarLocus" , "coadd" ], "reference" : { "doc" : "Ivezic, Z. et al. 2004, AN 325, SDSS data management and photometric quality assessment" , "page" : 586 , "url" : "https://onlinelibrary.wiley.com/doi/pdf/10.1002/asna.200410285" }}], "specs" : [{ "name" : "pipe_analysis.stellar_locus_width_wPerp.griPSF_wFit" , "type" : "threshold" , "threshold" : { "value" : 25.0 , "unit" : "mmag" , "operator" : "<=" }, "metadata_query" : { "filter_name" : "HSC-G^HSC-R^HSC-I" }, "tags" : [ "minimum" , "gri" , "stellar_locus_width" ]}, { "name" : "pipe_analysis.stellar_locus_width_xPerp.griPSF_xFit" , "type" : "threshold" , "threshold" : { "value" : 50.0 , "unit" : "mmag" , "operator" : "<=" }, "metadata_query" : { "filter_name" : "HSC-G^HSC-R^HSC-I" }, "tags" : [ "minimum" , "gri" , "stellar_locus_width" ]}], "meta" : { "name" : "griPSF-xFit" , "numberUsedInFit" : 5058 , "numberTotal" : 5070 , "mean" : 0.122 , "median" : 1.079 , "galacticExtinctionCorrection" : "GE applied: Per Object" , "camera" : "HSC" }} These metrics have been successfully defined in the SQuaSH sandbox instance following the instructions at https://sqr-019.lsst.io/#Dispatching-verification-jobs-to-SQUASH and the job was successfully dispatched, as seen in this snapshot of the sandbox chronograph (note there are two points: the first was measured on a single patch for testing, the second is the same rerun, but for full tract):
            Hide
            lauren Lauren MacArthur added a comment - - edited

            Might you be able to review this?  We are looking for someone with authority/familiarity of the proper way to get metrics computed within tasks defined, persisted, and uploaded to SQuaSH in the most workflow-friendly way and want to get it right from the start as we will be adding many more in the coming weeks (so you obviously came to mind, but if you are too overloaded at the moment, could you make suggestions for others you would trust with this?)

            I should also mention that since pipe_analysis still lives in lsst-dm, it is not currently officially subject to the strict code standards of lsst, so you can feel free to give it only a cursory look, but I will do my best to address any and all comments, so also feel free to nit-pick to your desire.

            Show
            lauren Lauren MacArthur added a comment - - edited Might you be able to review this?  We are looking for someone with authority/familiarity of the proper way to get metrics computed within tasks defined, persisted, and uploaded to SQuaSH in the most workflow-friendly way and want to get it right from the start as we will be adding many more in the coming weeks (so you obviously came to mind, but if you are too overloaded at the moment, could you make suggestions for others you would trust with this?) I should also mention that since pipe_analysis still lives in lsst-dm , it is not currently officially subject to the strict code standards of lsst , so you can feel free to give it only a cursory look, but I will do my best to address any and all comments, so also feel free to nit-pick to your desire.
            Hide
            lauren Lauren MacArthur added a comment -

            Jenkins is running

            Show
            lauren Lauren MacArthur added a comment - Jenkins is running
            Hide
            lauren Lauren MacArthur added a comment -

            For the (my!) record, this is the incantation for defining and deploying to the SQuaSH sandbox chronograph (run from within iPython):

            squash_api_url = "https://squash-restful-api-sandbox.lsst.codes"
             
            import getpass                                                                                       
            username = getpass.getuser()
            password = getpass.getpass(prompt='Password for user `{}`: '.format(username))
             
            import requests
            credentials = {'username': username, 'password': password}
            r = requests.post('{}/register'.format(squash_api_url), json=credentials)
            r.json()
            r = requests.post('{}/auth'.format(squash_api_url), json=credentials)
            r.json()
             
            import lsst.verify as verify
            verifyJob = verify.Job.load_metrics_package(subset="pipe_analysis")
             
            headers = {'Authorization': 'JWT {}'.format(r.json()['access_token'])}
            r = requests.post( '{}/metrics'.format(squash_api_url),  json={'metrics': verifyJob.json["metrics"]}, headers=headers)
            r.json()
            

            {'message': 'List of metrics successfully created.'}

            r = requests.post( '{}/specs'.format(squash_api_url), json={'specs': verifyJob.json["specs"]}, headers=headers)
            r.json()
            

            {'message': 'List of metric specificationss successfully created.'}

            The above series of commands only needs to be run once for a given set of metric/specs definitions to have them defined in SQuaSH.

            Now dispatch the persisted json file with the above metrics measured to with;

            %%bash -s "$squash_api_url" "$username" "$password" 
            export DYLD_LIBRARY_PATH=$LSST_LIBRARY_PATH 
            dispatch_verify.py --ignore-lsstsw --env jenkins --url $1 --user $2 --password $3 /datasets/hsc/repo/rerun/private/lauren/DM-21320/verify/color/tract-9813/colorAnalysis_verify_job.json
            

            verify.bin.dispatchverify.main INFO: Loading /datasets/hsc/repo/rerun/private/lauren/DM-21320/verify/color/tract-9813/colorAnalysis_verify_job.json
            verify.bin.dispatchverify.main INFO: Refreshing metric definitions from verify_metrics
            verify.bin.dispatchverify.main INFO: Inserting Jenkins CI environment metadata.
            verify.bin.dispatchverify.main INFO: Uploading Job JSON to https://squash-restful-api-sandbox.lsst.codes.
            verify.squash.get INFO: GET https://squash-restful-api-sandbox.lsst.codes status: 200
            verify.squash.post INFO: POST https://squash-restful-api-sandbox.lsst.codes/auth status: 200
            verify.squash.post INFO: POST https://squash-restful-api-sandbox.lsst.codes/job status: 202

            The metric should then be visible in the sandbox as shown in the attached snapshot.

            Show
            lauren Lauren MacArthur added a comment - For the (my!) record, this is the incantation for defining and deploying to the SQuaSH sandbox chronograph (run from within iPython): squash_api_url = "https://squash-restful-api-sandbox.lsst.codes"   import getpass username = getpass.getuser() password = getpass.getpass(prompt = 'Password for user `{}`: ' . format (username))   import requests credentials = { 'username' : username, 'password' : password} r = requests.post( '{}/register' . format (squash_api_url), json = credentials) r.json() r = requests.post( '{}/auth' . format (squash_api_url), json = credentials) r.json()   import lsst.verify as verify verifyJob = verify.Job.load_metrics_package(subset = "pipe_analysis" )   headers = { 'Authorization' : 'JWT {}' . format (r.json()[ 'access_token' ])} r = requests.post( '{}/metrics' . format (squash_api_url), json = { 'metrics' : verifyJob.json[ "metrics" ]}, headers = headers) r.json() {'message': 'List of metrics successfully created.'} r = requests.post( '{}/specs' . format (squash_api_url), json = { 'specs' : verifyJob.json[ "specs" ]}, headers = headers) r.json() {'message': 'List of metric specificationss successfully created.'} The above series of commands only needs to be run once for a given set of metric/specs definitions to have them defined in SQuaSH. Now dispatch the persisted json file with the above metrics measured to with; % % bash - s "$squash_api_url" "$username" "$password" export DYLD_LIBRARY_PATH = $LSST_LIBRARY_PATH dispatch_verify.py - - ignore - lsstsw - - env jenkins - - url $ 1 - - user $ 2 - - password $ 3 / datasets / hsc / repo / rerun / private / lauren / DM - 21320 / verify / color / tract - 9813 / colorAnalysis_verify_job.json verify.bin.dispatchverify.main INFO: Loading /datasets/hsc/repo/rerun/private/lauren/ DM-21320 /verify/color/tract-9813/colorAnalysis_verify_job.json verify.bin.dispatchverify.main INFO: Refreshing metric definitions from verify_metrics verify.bin.dispatchverify.main INFO: Inserting Jenkins CI environment metadata. verify.bin.dispatchverify.main INFO: Uploading Job JSON to https://squash-restful-api-sandbox.lsst.codes . verify.squash.get INFO: GET https://squash-restful-api-sandbox.lsst.codes status: 200 verify.squash.post INFO: POST https://squash-restful-api-sandbox.lsst.codes/auth status: 200 verify.squash.post INFO: POST https://squash-restful-api-sandbox.lsst.codes/job status: 202 The metric should then be visible in the sandbox as shown in the attached snapshot.
            Hide
            afausti Angelo Fausti added a comment -

            Looks great Lauren MacArthur!

            Show
            afausti Angelo Fausti added a comment - Looks great Lauren MacArthur !
            Hide
            lauren Lauren MacArthur added a comment -

            Thanks Angelo Fausti. Merged and done!

            Show
            lauren Lauren MacArthur added a comment - Thanks Angelo Fausti . Merged and done!

              People

              Assignee:
              lauren Lauren MacArthur
              Reporter:
              lauren Lauren MacArthur
              Reviewers:
              Angelo Fausti
              Watchers:
              Angelo Fausti, Dan Taranu, Lauren MacArthur, Sophie Reed, Yusra AlSayyad
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Jenkins

                  No builds found.