From 04a4694122b288ce69bd55413ef4fc2165847fd1 Mon Sep 17 00:00:00 2001
From: chausman <chausman@nrao.edu>
Date: Tue, 29 Jun 2021 15:16:22 -0600
Subject: [PATCH] WS-271: CMS imaging templates

---
 ...2fcb74a8c_add_std_cms_imaging_templates.py | 79 +++++++++++++++----
 1 file changed, 65 insertions(+), 14 deletions(-)

diff --git a/schema/versions/a832fcb74a8c_add_std_cms_imaging_templates.py b/schema/versions/a832fcb74a8c_add_std_cms_imaging_templates.py
index 5c54a4a3d..159d9e53a 100644
--- a/schema/versions/a832fcb74a8c_add_std_cms_imaging_templates.py
+++ b/schema/versions/a832fcb74a8c_add_std_cms_imaging_templates.py
@@ -10,21 +10,23 @@ import sqlalchemy as sa
 
 
 # revision identifiers, used by Alembic.
-revision = 'a832fcb74a8c'
-down_revision = '6ce7b4b8a9ea'
+revision = "a832fcb74a8c"
+down_revision = "6ce7b4b8a9ea"
 branch_labels = None
 depends_on = None
 
 condor_content = """executable = std_cms_imaging.sh
-arguments = {{product_locator}} metadata.json PPR.xml
+arguments = metadata.json PPR.xml
 
 output = imaging.out
 error = imaging.err
 log = condor.log
 
 SBIN_PATH = /lustre/aoc/cluster/pipeline/$ENV(CAPO_PROFILE)/workspaces/sbin
+CMS_PATH = /lustre/aoc/cluster/pipeline/$ENV(CAPO_PROFILE)/workspaces/spool/{{relative_path}}/working
 should_transfer_files = yes
-transfer_input_files = $(SBIN_PATH)/.matplotlib, $(SBIN_PATH)/pycapo, $(SBIN_PATH)/framework.sh, $(SBIN_PATH)/productfetcher, $(SBIN_PATH)/casa_envoy, $(SBIN_PATH)/vela, $(SBIN_PATH)/conveyor, ./PPR.xml, ./metadata.json
+transfer_input_files = $(SBIN_PATH)/.matplotlib, $(SBIN_PATH)/pycapo, $(SBIN_PATH)/framework.sh, $(SBIN_PATH)/productfetcher,
+ $(SBIN_PATH)/casa_envoy, $(SBIN_PATH)/vela, $(SBIN_PATH)/conveyor, ./PPR.xml, ./metadata.json, $(CMS_PATH)/{{cms_name}}
 
 request_memory = {{ramInGb}}
 getenv = True
@@ -40,12 +42,9 @@ export HOME=$TMPDIR
 
 ./framework.sh -d .
 chmod 770 .
-cd rawdata/
-../productfetcher --product-locator $1
-cd ../
-./casa_envoy --standard-cmsimage $2 $3
-#  find out expected behavior for standard type image delivery
-# ./conveyor --deliver $2
+mv {{cms_name}} ./working
+./casa_envoy --standard-cmsimage $1 $2
+./conveyor --deliver-image $1
 
 """
 
@@ -61,6 +60,7 @@ metadata_content = """{
     "observer": "{{observer}}"
   },
   "destinationDirectory": "{{root_directory}}/{{relative_path}}"
+  "calibrationSourceDirectory":"{{cal_directory}}"
 }
 """
 
@@ -86,15 +86,65 @@ ppr_content = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
                     <Value>Undefined</Value>
                 </Intents>
             </ProcessingIntents>
-
-            <!--TODO: find correct procedure!-->
-
+            <ProcessingProcedure>
+                <ProcedureTitle>hifv_contimage</ProcedureTitle>
+                <ProcessingCommand>
+                    <Command xmlns="">hifv_importdata</Command>
+                    <ParameterSet>
+                    </ParameterSet>
+                </ProcessingCommand>
+                <ProcessingCommand>
+                    <Command xmlns="">hif_mstransform</Command>
+                    <ParameterSet>
+                    </ParameterSet>
+                </ProcessingCommand>
+                <ProcessingCommand>
+                    <Command xmlns="">hif_checkproductsize</Command>
+                    <ParameterSet>
+                        <Parameter>
+                            <Keyword xmlns="">maximsize</Keyword>
+                            <Value xmlns="">16384</Value>
+                        </Parameter>
+                    </ParameterSet>
+                </ProcessingCommand>
+                <ProcessingCommand>
+                    <Command xmlns="">hif_makeimlist</Command>
+                    <ParameterSet>
+                        <Parameter>
+                            <Keyword xmlns="">specmode</Keyword>
+                            <Value xmlns="">cont</Value>
+                        </Parameter>
+                    </ParameterSet>
+                </ProcessingCommand>
+                <ProcessingCommand>
+                    <Command xmlns="">hif_makeimages</Command>
+                    <ParameterSet>
+                        <Parameter>
+                            <Keyword xmlns="">hm_masking</Keyword>
+                            <Value xmlns="">none</Value>
+                        </Parameter>
+                        <Parameter>
+                            <Keyword xmlns="">hm_cyclefactor</Keyword>
+                            <Value xmlns="">3.0</Value>
+                        </Parameter>
+                    </ParameterSet>
+                </ProcessingCommand>
+                <ProcessingCommand>
+                    <Command xmlns="">hifv_exportdata</Command>
+                    <ParameterSet>
+                        <Parameter>
+                            <Keyword xmlns="">imaging_products_only</Keyword>
+                            <Value xmlns="">True</Value>
+                        </Parameter>
+                    </ParameterSet>
+                </ProcessingCommand>
+            </ProcessingProcedure>
             <DataSet>
                 <RelativePath>{{relative_path}}</RelativePath>
                 <SdmIdentifier>{{sdmId}}.ms</SdmIdentifier>
                 <DataType>asdm</DataType>
             </DataSet>
-        </ProcessingRequest>
+        </ProcessingRequest>0
     </ProcessingRequests>
     <ResultsProcessing>
         <ArchiveResults>false</ArchiveResults>
@@ -106,6 +156,7 @@ ppr_content = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
         <PipelineOperatorAddress>Unknown</PipelineOperatorAddress>
     </ResultsProcessing>
 </ns2:SciPipeRequest>
+
 """
 
 
-- 
GitLab