Skip to content

Commit

Permalink
#22 fix workdir issue
Browse files Browse the repository at this point in the history
webgisdeveloper committed Feb 1, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 6608dee commit 45aace5
Showing 3 changed files with 28 additions and 4 deletions.
18 changes: 18 additions & 0 deletions webAPI/GPS_service.py
Original file line number Diff line number Diff line change
@@ -6,12 +6,14 @@
import random, os, json, datetime

from getCoseismic import getCoseismic
from getInterpolation import getInterpolation
from getPostseismic import getPostseismic
from getDisplacement import getDisplacement
from getVelocities import getVelocities
from getModel import getModel
from getDiff import getDiff


from copy import deepcopy

class objdict(dict):
@@ -174,6 +176,22 @@ def generateKML(args):
paras = objdict(inputdict)
getDisplacement(paras)

if "interpolation" in item.lower():
# run getDisplacement first
inputdict['output'] = outputdir + os.path.sep + outputprefix + "displacement"
paras = objdict(inputdict)
getDisplacement(paras)
# new para dict
paradict={}
paradict['datatable'] = inputdict['output']+"_table.txt"
paradict['grid_space'] = 0.018
paradict['interpolation_type'] = 'linear'
paradict['azimuth'] = -5
paradict['elevation'] = 60
paras_interpolation = objdict(paradict)
getInterpolation(paras_interpolation)


if "model" in item.lower():
inputdict['output'] = outputdir + os.path.sep + outputprefix + "model"
paras = objdict(inputdict)
12 changes: 9 additions & 3 deletions webAPI/getInterpolation.py
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
-- requirements: pykrige
"""

import os
import math
import argparse
import numpy as np
@@ -34,9 +35,13 @@ def main():

def getInterpolation(results):
"""run interpolation"""
print(results)

datatable = results.datatable

curdir = os.getcwd()

datatable = os.path.basename(results.datatable)
wkdir = os.path.dirname(results.datatable)
if os.path.exists(wkdir):
os.chdir(wkdir)
grid_space = results.grid_space
interpolation_type = results.interpolation_type
azimuth = results.azimuth
@@ -62,6 +67,7 @@ def getInterpolation(results):
create_contour_overlay(
interpolated_values['Lon'], interpolated_values['Lat'], interpolated_values[entry])

os.chdir(curdir)

def to_los_disp(ux, uy, uv, azimuth=-5, elevation=60):
g = [math.sin(azimuth)*math.cos(elevation), math.cos(azimuth)
2 changes: 1 addition & 1 deletion webAPI/run_debug.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export FLASK_APP=GPS_service_API.py
export FLASK_DEBUG=1
python -m flask run --host=0.0.0.0
python -m flask run --host=0.0.0.0 --port=5500

0 comments on commit 45aace5

Please sign in to comment.