Skip to content

Commit

Permalink
hardcode path to data
Browse files Browse the repository at this point in the history
  • Loading branch information
nilshempelmann committed Jun 18, 2024
1 parent 59254c4 commit 050b68c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
7 changes: 6 additions & 1 deletion albatross/atmos_ocean_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
LOGGER = logging.getLogger("PYWPS")



def openDAPsst(version = '3b', debug = False, anomalies = True, **kwargs):
"""
This function downloads data from the new ERSSTv3b on the IRI data library
kwargs should contain: startyr, endyr, startmon, endmon, nbox
"""
from utils import int_to_month
from albatross.utils import int_to_month
from os.path import isfile
from pydap.client import open_url
from numpy import arange
Expand Down Expand Up @@ -57,6 +58,8 @@ def openDAPsst(version = '3b', debug = False, anomalies = True, **kwargs):

fp = fp + '_anoms' if anomalies else fp + '_ssts'

print( 'Path for temporary file: %s' % (fp))

seasonal_var = namedtuple('seasonal_var', ('data','lat','lon'))

#if isfile(fp):
Expand Down Expand Up @@ -221,6 +224,8 @@ def load_clim_file(fp, debug = False):
import numpy as np
import pandas as pd

print('load_clim_file function with %s' % fp)

#First get the description and years
f = open(fp)
description = f.readline()
Expand Down
36 changes: 20 additions & 16 deletions albatross/processes/wps_drought.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,22 +122,26 @@ def _handler(request, response):

# sst= request.inputs['sst'][0].data

import shutil
import tempfile
import urllib.request

with urllib.request.urlopen(request.inputs['indicator'][0].data) as response:
with tempfile.NamedTemporaryFile(delete=False) as tmp_indicator:
shutil.copyfileobj(response, tmp_indicator)
with open(tmp_indicator.name) as index_file:
pass

with urllib.request.urlopen(request.inputs['pr'][0].data) as response:
with tempfile.NamedTemporaryFile(delete=False) as tmp_pr:
shutil.copyfileobj(response, tmp_pr)
with open(tmp_pr.name) as clim_file:
pass

# import shutil
# import tempfile
# import urllib.request

# with urllib.request.urlopen(request.inputs['indicator'][0].data) as response:
# with tempfile.NamedTemporaryFile(delete=False) as tmp_indicator:
# shutil.copyfileobj(response, tmp_indicator)
# with open(tmp_indicator.name) as index_file:
# pass

# with urllib.request.urlopen(request.inputs['pr'][0].data) as response:
# with tempfile.NamedTemporaryFile(delete=False) as tmp_pr:
# shutil.copyfileobj(response, tmp_pr)
# with open(tmp_pr.name) as clim_file:
# pass
import os
os.getcwd()

index_file = os.getcwd() + '/DATA/nao.txt'
clim_file = os.getcwd() + '/DATA/APGD_prcpComo.txt'
filename = 'testComoNAO'

# #### USER INPUT ####
Expand Down

0 comments on commit 050b68c

Please sign in to comment.