Skip to content

Commit

Permalink
update url in api scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinElms committed Nov 26, 2024
1 parent 5ccdd91 commit 77ddcb5
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 29 deletions.
2 changes: 1 addition & 1 deletion plotting/templates/python_csv_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def requestFile():


# Assemble full request
base_url = "https://navigator.oceansdata.ca/api/v2.0/plot/{p}?"
base_url = "https://oceannavigator.ca/api/v2.0/plot/{p}?"
url = base_url + urlencode({{"query": json.dumps(query)}}) + '&save=True&format=csv&size=10x7&dpi=144'
print(url)

Expand Down
2 changes: 1 addition & 1 deletion plotting/templates/python_plot_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def requestFile():


# Assemble full request
base_url = "https://navigator.oceansdata.ca/api/v2.0/plot/{p}?"
base_url = "https://oceannavigator.ca/api/v2.0/plot/{p}?"
url = base_url + urlencode({{"query": json.dumps(query)}}) + "&format=png&size=10x7&dpi=" + str(dpi)
print(url)

Expand Down
4 changes: 1 addition & 3 deletions plotting/templates/python_subset_template.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import requests
import os
import shutil
from urllib.request import urlopen
from contextlib import closing


def requestFile():
Expand All @@ -11,7 +9,7 @@ def requestFile():


# Assemble full request
base_url = "https://navigator.oceansdata.ca/api/v2.0/subset/?"
base_url = "https://oceannavigator.ca/api/v2.0/subset/"+query["dataset_name"]+"/"+query["variables"]+"?"
url = base_url
for key in query:
url += f"&{{key}}={{query[key]}}"
Expand Down
20 changes: 0 additions & 20 deletions plotting/templates/rSUBSETtemplate.txt

This file was deleted.

2 changes: 1 addition & 1 deletion plotting/templates/r_csv_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dpi <- 144
queryObj <- fromJSON(query)
fname <- paste("ONAV_CSV_", queryObj["dataset"],"_", queryObj["variable"],".csv", sep="")
gsub("[\r\n]", "", query)
base_url <- "https://navigator.oceansdata.ca/api/v2.0/plot/{p}?"
base_url <- "https://oceannavigator.ca/api/v2.0/plot/{p}?"
url <- paste(base_url,"&query=",URLencode(query),"&save=True&format=csv&size=10x7&dpi=",toString(dpi), sep="")
print(url)

Expand Down
2 changes: 1 addition & 1 deletion plotting/templates/r_plot_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ queryObj <- fromJSON(query)
fname <- paste("ONAV_PLOT_", queryObj["dataset"],"_", queryObj["variable"],".png", sep="")

gsub("[\r\n]", "", query)
base_url <- "https://navigator.oceansdata.ca/api/v2.0/plot/{p}?"
base_url <- "https://oceannavigator.ca/api/v2.0/plot/{p}?"
url <- paste(base_url,"&query=",URLencode(query),"&dpi=",toString(dpi), sep="")
print(url)

Expand Down
18 changes: 16 additions & 2 deletions plotting/templates/r_subset_template.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
library(jsonlite)


query <- '{q}'

print("NOT IMPLEMENTED")
queryObj <- fromJSON(query)
fname <- "script_output.nc"

base_url <- paste("https://oceannavigator.ca/api/v2.0/subset/", queryObj["dataset_name"], "/", queryObj["variables"], "?", sep="")
url <- base_url

for (key in names(queryObj))
{{
url <- paste(url, "&", key, "=", queryObj[key], sep="")
}}

url <- gsub(",[\r\n]", "", url)
print(url)

print(paste("Downloading file in location ",getwd(), " and exiting..."))
download.file(url, fname, method="auto", mode="wb")

0 comments on commit 77ddcb5

Please sign in to comment.