def get_timeMatrix(): # load data stationInfo = getJsonData('stationAppearTime.json') stationIDList = get_stationIDList() # compute time matrix timeMatrix = [] for row in stationIDList: rowStation = stationInfo[row] time = [] for col in stationIDList: colStation = stationInfo[col] time.append((parse(rowStation[0]) - parse(colStation[0])).days) timeMatrix.append(time) return timeMatrix
def get_distanceMatrix(): # load data stationInfo = getJsonData('stationAppearTime.json') stationIDList = get_stationIDList() # compute the distance matrix distanceMatrix = [] for row in stationIDList: rowStation = stationInfo[row] distance = [] for col in stationIDList: colStation = stationInfo[col] distance.append( haversine(float(rowStation[2]), float(rowStation[1]), float(colStation[2]), float(colStation[1]))) distanceMatrix.append(distance) return distanceMatrix
from utils.getJsonData import * from utils.dayType import * from utils.symbols import EMPTY_DATA from visualization.TimeSeries import timeSeries from dateutil.parser import parse stationAppearTimeDict = getJsonData('stationAppearTime.json') absorptionAnalysis = getJsonData('absorptionAnalysis.json') absorptionAnalysisDailyDict = getJsonData('absorptionAnalysisDaily.json') absorptionAnalysisDaily = absorptionAnalysisDailyDict[ 'absorptionAnalysisDaily'] workdayDict = absorptionAnalysisDailyDict['workday'] holidayDict = absorptionAnalysisDailyDict['holiday'] threshold = 0.2 # obvious obviousCounter = 0 obviousStation = [] obviousNNStation = [] obviousPairStation = [] # unchanged unchangedCounter = 0 unchangedPairStation = [] # reversed reversedCounter = 0 reversedPairStation = [] dateTimeMode = '%Y-%m-%d' # all station
for i in range(distanceMatrix.__len__()): nearStation = [] for j in range(distanceMatrix[i].__len__()): if i != j: if distanceMatrix[i][j] < d: nearStation.append(j) nearStationMatrix.append(nearStation) return nearStationMatrix if __name__ == '__main__': S_STAR = [] S_STAR_NN = {} # load data stationInfo = getJsonData('stationAppearTime.json') stationIDList = get_stationIDList() # compute the distance matrix distanceMatrix = get_distanceMatrix() # compute time matrix # timeMatrix = get_timeMatrix() # get station within distanceThreshold nearStationMatrix = get_near_staion_list(distanceMatrix, distanceThresholdAbsorption) nearStationMatrix_sti = get_near_staion_list(distanceMatrix, distanceThresholdStimulation) # Rule 1 : nearStationMatrix 移除建在一个月后的临近站点 如果有站点建在一个月内,直接清空
team_overview_api = "https://nai.nasa.gov/api/reports/team-reports/?year=2016&team=" team_slugs = getTeamSlugs(2016) # Only for Testing #team_slugs = ["arc", ] os.system("mkdir media") os.system("mkdir reports") try: document_title = "Overview and Executive Summary of NAI Team" exec_sum_tag = "this section should be written as a coherent piece independent of the individual project reports" interdisciplinarity_tag = "* Interdisciplinary research" collab_tag = "Has this project involved collaboration that has benefitted from the NAI?" field_site_tag = "Related links: websites, publications, articles, videos" for team_slug in team_slugs: team_info_json = getJsonData(nai_team_api, team_slug) # Due to CAN 5 extension, we need to catch for CAN 6 or 7. - JH 1/12/17 if len(team_info_json) == 2: for team in team_info_json: if team.get('can') == 7 or team.get('can') == 6: team_info_json = team else: team_info_json = team_info_json[0] team_project_report_json = getJsonData(team_project_report_api, team_slug)[0] team_overview_json = getJsonData(team_overview_api, team_slug)[0] team_exec_json = getJsonData(team_overview_api, team_slug)[0] #team_pubs_data = getJsonData(mr_team_api, team_slug) # See L74 - JH 11/28/16 # logos = team_info_json.get('logos')