-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9fbedc6
commit 2aff610
Showing
4 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import os | ||
import sys | ||
root_path = os.getcwd() | ||
sys.path.append(root_path) | ||
import iri2016 | ||
from fastapi import FastAPI | ||
from fastapi.middleware.cors import CORSMiddleware | ||
app = FastAPI() | ||
origins = [ | ||
"http://localhost", | ||
"http://localhost:8080", # Vue应用运行的地址 | ||
] | ||
app.add_middleware( | ||
CORSMiddleware, | ||
allow_origins=["*"], # 允许所有源 | ||
allow_credentials=True, | ||
allow_methods=["*"], # 允许所有方法 | ||
allow_headers=["*"], # 允许所有头 | ||
) | ||
|
||
@app.get("/") | ||
async def root(): | ||
return {"message": "Hello IRI"} | ||
|
||
# 获取测试数据 | ||
@app.post("/test_ne") | ||
async def test_ne(information: dict): | ||
time = information['time'] | ||
altitude_start = int(information['artitude_start']) | ||
altitude_stop = int(information['artitude_stop']) | ||
altitude_stepsize = int(information['artitude_stepsize']) | ||
longitude = int(information['longitude']) | ||
latitude = int(information['latitude']) | ||
|
||
arr = iri2016.IRI(time, (altitude_start, altitude_stop, altitude_stepsize), longitude, latitude) | ||
arr_ne = arr['ne'].to_numpy().tolist() | ||
arr_nOp = arr['nO+'].to_numpy().tolist() | ||
return {"ne": arr_ne, "nOp": arr_nOp} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import matplotlib.pyplot as plt | ||
import iri2016 | ||
import numpy as np | ||
from joblib import Parallel, delayed | ||
import time | ||
import iri2016.profile as iri | ||
from datetime import datetime, timedelta | ||
from matplotlib.pyplot import figure, show | ||
import pandas as pd | ||
iri2016.IRI('2020-12-31T00',(100, 1000, 10.0),80,120) #截止到2020-12-31 | ||
import math | ||
def get_timeSeq(start_time, stop_time, interval_min): | ||
time_seq = [] | ||
start = datetime.strptime(start_time, '%Y-%m-%d %H') | ||
end = datetime.strptime(stop_time, '%Y-%m-%d %H') | ||
time_interval = end - start | ||
minutes = (time_interval.seconds)/60 + time_interval.days*24*60 | ||
tec_count = math.ceil(minutes/interval_min) | ||
print("tec_count = ", tec_count) | ||
delta = timedelta(minutes=interval_min) | ||
for i in range(tec_count): | ||
data = (start + delta*i).strftime('%Y-%m-%d %H') | ||
time_seq.append('{}T{}'.format(data[:-3], data[-2:])) | ||
return time_seq, tec_count | ||
def cal_TEC(time_seq, high_range, lat_seq, lon_seq): | ||
print(time_seq[0], "====", time_seq[-1]) | ||
start = time.time() | ||
result = Parallel(n_jobs=-20)(delayed(lambda t,h,lat,lon:iri2016.IRI(t,h,lat,lon).TEC.values[0])(time,high_range,i,j)for time in time_seq for i in lat_seq for j in lon_seq) | ||
end = time.time() | ||
print('{:.4f} s\n'.format(end-start)) | ||
return result | ||
start_time = '2011-01-04 00' | ||
# start_time = '2017-04-21 00' | ||
end_time = '2011-01-04 01' | ||
interval_min = 60 #每小时监测一个tec | ||
time_seq, tec_count = get_timeSeq(start_time, end_time, interval_min) | ||
|
||
lat_seq = [lat for lat in range(-90,91,3)] | ||
lon_seq = [lan for lan in range(-180,181,6)] | ||
high_range = [100,1000,10000] | ||
tec_result = cal_TEC(time_seq, high_range, lat_seq, lon_seq) | ||
tec_result = np.array(tec_result).reshape(1, -1, 61) | ||
|
||
print(tec_result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import iri2016 | ||
import numpy as np | ||
|
||
s = iri2016.IRI("2020-12-31T00", (100, 1000, 10), 80, 120) | ||
x = s['ne'].to_numpy() | ||
|
||
print(x[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import numpy as np | ||
import iri2016 | ||
|
||
nlons = 40 | ||
nlats = 40 | ||
|
||
ALT_min = 60 | ||
ALT_max = 100 | ||
nALT = 30 | ||
|
||
ALT_step = (100 - 60) / (30 - 1) | ||
|
||
LON = np.linspace(-180,180,nlons) | ||
LAT = np.linspace(-90,90,nlats) | ||
ALT = np.linspace(ALT_min, ALT_max, nALT) | ||
|
||
GLON0, GLAT0 = np.meshgrid(LON, LAT) | ||
|
||
GLON, GLAT, GALT = np.meshgrid(LON, LAT, ALT) | ||
Ne = np.zeros((np.shape(GLON))) | ||
for i in range(nlons): | ||
for j in range(nlats): | ||
temp = iri2016.IRI('2016-9-27-18T', [ALT_min, ALT_max, ALT_step], GLAT0[i, j], GLON0[i, j]) | ||
Ne[i, j, :] = temp.ne |