1#!/usr/bin/env cwl-runner
2### Downloader of AQS Data
3# Copyright (c) 2021. Harvard University
4#
5# Developed by Research Software Engineering,
6# Faculty of Arts and Sciences, Research Computing (FAS RC)
7# Author: Michael A Bouzinier
8#
9# Licensed under the Apache License, Version 2.0 (the "License");
10# you may not use this file except in compliance with the License.
11# You may obtain a copy of the License at
12#
13# http://www.apache.org/licenses/LICENSE-2.0
14#
15# Unless required by applicable law or agreed to in writing, software
16# distributed under the License is distributed on an "AS IS" BASIS,
17# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18# See the License for the specific language governing permissions and
19# limitations under the License.
20#
21
22cwlVersion: v1.2
23class: CommandLineTool
24baseCommand: [wget]
25
26requirements:
27 InlineJavascriptRequirement: {}
28 ResourceRequirement:
29 coresMin: 0.5
30 NetworkAccess:
31 networkAccess: True
32 EnvVarRequirement:
33 envDef:
34 HTTP_PROXY: "$('proxy' in inputs? inputs.proxy: null)"
35 HTTPS_PROXY: "$('proxy' in inputs? inputs.proxy: null)"
36 NO_PROXY: "localhost,127.0.0.1,172.17.0.1"
37
38doc: |
39 This tool downloads AQS data from EPA website
40
41inputs:
42 aggregation:
43 type: string
44 doc: "Aggregation type: annual or daily"
45 parameter_code:
46 type: string
47 doc: |
48 Parameter code. Either a numeric code (e.g. 88101, 44201)
49 or symbolic name (e.g. PM25, NO2).
50 See more: [AQS Code List](https://www.epa.gov/aqs/aqs-code-list)
51 year:
52 type: string
53 doc: Year to download
54 proxy:
55 type: string
56 doc: Proxy for connection
57
58arguments:
59 - position: 1
60 valueFrom: $("https_proxy=" + inputs.proxy)
61 prefix: -e
62 - position: 2
63 valueFrom: |
64 ${
65 if (inputs.aggregation == "annual") {
66 return "https://aqs.epa.gov/aqsweb/airdata/annual_conc_by_monitor_" + inputs.year + ".zip";
67 } else {
68 var parameters = {"NO2": 42602, "OZONE": 44201, "PM25": 88101, "MIN_TEMP": 68103, "MAX_TEMP": 68104};
69 var parameter = parameters[inputs.parameter_code] || inputs.parameter_code;
70
71 return "https://aqs.epa.gov/aqsweb/airdata/daily_" + parameter + "_" + inputs.year + ".zip";
72 }
73 }
74
75outputs:
76 data:
77 type: File
78 outputBinding:
79 glob: "*.*"