#add message

This commit is contained in:
xieshen 2021-04-07 10:01:15 +08:00
parent 3933004f4a
commit c4f6bbe43b
3 changed files with 1449 additions and 58 deletions

View File

@ -111,8 +111,6 @@
</div>
</div>
</div>
</div>
</div>
@ -122,12 +120,62 @@
<div class="panel-body">
<div class="table-box">
<div class="panel panel-default" style="margin-top: 5px">
<ul class="nav nav-pills" hidden id="nav">
<ul class="nav nav-pills" id="menu" hidden>
<li role="presentation" class="active"><a onclick="createQuxian()">曲线图</a></li>
<li role="presentation" class="active"><a onclick="createGif()">高程图</a></li>
</ul>
<div id="menu_element" style="margin-top: 20px" hidden>
<a class="btn btn-default" href="#" role="button" id="He" onclick="createGifHe()">He</a>
<a class="btn btn-default" href="#" role="button" id="O" onclick="createGifO()">O</a>
<a class="btn btn-default" href="#" role="button" id="N2" onclick="createGifN2()">N2</a>
<a class="btn btn-default" href="#" role="button" id="O2" onclick="createGifO2()">O2</a>
<a class="btn btn-default" href="#" role="button" id="Ar" onclick="createGifAr()">Ar</a>
<a class="btn btn-default" href="#" role="button" id="rho" onclick="createGifrho()">rho</a>
<a class="btn btn-default" href="#" role="button" id="Texo" onclick="createGifTexo()">Texo</a>
<a class="btn btn-default" href="#" role="button" id="Talt" onclick="createGifTalt()">Talt</a>
<a class="btn btn-default" href="#" role="button" id="lst" onclick="createGiflst()">lst</a>
<a class="btn btn-default" href="#" role="button" id="Ap" onclick="createGifAp()">Ap</a>
<a class="btn btn-default" href="#" role="button" id="f107" onclick="createGiff107()">f107</a>
<a class="btn btn-default" href="#" role="button" id="f107a" onclick="createGiff107a()">f107a</a>
</div>
<div class="panel-body">
<div id="graph1" style="height: 500px;"></div>
</div>
<div class="panel-body">
<div id="graph2" style="height: 500px;"></div>
</div>
<div class="panel-body">
<div id="graph3" style="height: 500px;"></div>
</div>
<div class="panel-body">
<div id="graph4" style="height: 500px;"></div>
</div>
<div class="panel-body">
<div id="graph5" style="height: 500px;"></div>
</div>
<div class="panel-body">
<div id="graph6" style="height: 500px;"></div>
</div>
<div class="panel-body">
<div id="graph7" style="height: 500px;"></div>
</div>
<div class="panel-body">
<div id="graph8" style="height: 500px;"></div>
</div>
<div class="panel-body">
<div id="graph9" style="height: 500px;"></div>
</div>
<div class="panel-body">
<div id="graph10" style="height: 500px;"></div>
</div>
<div class="panel-body">
<div id="graph11" style="height: 500px;"></div>
</div>
<div class="panel-body">
<div id="graph12" style="height: 500px;"></div>
</div>
<div class="panel-body">
<div id="graph13" style="height: 500px;"></div>
</div>
</div>
@ -225,8 +273,7 @@
$("#tabs").append(results)
}
}
else {
} else {
if (parseInt(month) < 12) {
month = parseInt(month) + 1
{#for (var i = 1; i <= parseInt(month); i++) {#}
@ -275,6 +322,22 @@
function runModel() {
$("#hint").empty()
$("#menu").show()
$("#graph1").show()
$("#graph2").hide()
$("#graph3").hide()
$("#graph4").hide()
$("#graph5").hide()
$("#graph6").hide()
$("#graph7").hide()
$("#graph8").hide()
$("#graph9").hide()
$("#graph10").hide()
$("#graph11").hide()
$("#graph12").hide()
$("#graph13").hide()
$("#menu_element").hide()
var yearList = new Array();
var monthList = new Array();
@ -282,6 +345,8 @@
var lonList = new Array();
var latList = new Array();
var altList = new Array();
var lon;
var lat
var Check = $("table input[name='checkItem']:checked");//在table中找input下类型为checkbox属性为选中状态的数据
Check.each(function () {//遍历
@ -289,8 +354,8 @@
var year = row.find("[name='year']").html();//获取name='Sid'的值
var month = row.find("[name='month']").html();
var day = row.find("[name='day']").html();
var lon = row.find("[name='lon']").html();
var lat = row.find("[name='lat']").html();
lon = row.find("[name='lon']").html();
lat = row.find("[name='lat']").html();
var alt = row.find("[name='alt']").html();
for (var i = 0; i < month.length; i++) {
@ -901,47 +966,14 @@
$("#hint").html('请确保只有一个数据序列变化,其他参数一致。')
}
console.log(lonList)
}
function createGif() {
$("#graph1").empty()
$("#nav").hide()
var yearList = new Array();
var monthList = new Array();
var dayList = new Array();
var lonList = new Array();
var latList = new Array();
var altList = new Array();
var lon;
var lat;
var Check = $("table input[name='checkItem']:checked");//在table中找input下类型为checkbox属性为选中状态的数据
Check.each(function () {//遍历
var row = $(this).parent("td").parent("tr");//获取选中行
var year = row.find("[name='year']").html();//获取name='Sid'的值
var month = row.find("[name='month']").html();
var day = row.find("[name='day']").html();
lon = row.find("[name='lon']").html();
lat = row.find("[name='lat']").html();
var alt = row.find("[name='alt']").html();
for (var i = 0; i < month.length; i++) {
yearList.push(year)
monthList.push(month)
dayList.push(day)
lonList.push(lon)
latList.push(lat)
altList.push(alt)
}
})
console.log(lat, lon)
if (lon.toString().indexOf(';') == -1 && lat.indexOf(';') == -1) {
$("#hint").html('请输入正确的数据格式。')
$("#hint").html('计算动态图请输入正确的数据格式。')
} else {
showWaiting()
$.getJSON('/create/gif/', {
$.getJSON('/create/gif/He/', {
'yearList': JSON.stringify(yearList),
'monthList': JSON.stringify(monthList),
'dayList': JSON.stringify(dayList),
@ -957,16 +989,435 @@
}
console.log(imgage)
size = imgage.length
{#setTimeout(chImg(), 5000);#}
$("#graph2").html("<div style='text-align: center'><img style='height: 400px;width: 600px' src='http://210.77.68.250:8004/static/image/He/" + res.t + "/nrlmsise00_He.gif'></div>")
{#function chImg() {#}
{#for (var j = 0; j < size; j++) {#}
{#$("#graph2").append("<img style='height: 400px' src='" + res.image[j] + "'>")#}
})
$.getJSON('/create/gif/O/', {
'yearList': JSON.stringify(yearList),
'monthList': JSON.stringify(monthList),
'dayList': JSON.stringify(dayList),
'lonList': JSON.stringify(lonList),
'latList': JSON.stringify(latList),
'altList': JSON.stringify(altList)
}, function (res) {
hideWaiting()
console.log(res)
var imgage = new Array()
for (var i = 0; i < res.image.length; i++) {
imgage.push(res.image[i])
}
console.log(imgage)
size = imgage.length
$("#graph3").html("<div style='text-align: center'><img style='height: 400px;width: 600px' src='http://210.77.68.250:8004/static/image/O/" + res.t + "/nrlmsise00_O.gif'></div>")
$("#graph1").html("<div style='text-align: center'><img style='height: 400px;width: 600px' src='http://210.77.68.250:8004/static/image/" + res.t + "/nrlmsise00.gif'></div>")
})
$.getJSON('/create/gif/N2/', {
'yearList': JSON.stringify(yearList),
'monthList': JSON.stringify(monthList),
'dayList': JSON.stringify(dayList),
'lonList': JSON.stringify(lonList),
'latList': JSON.stringify(latList),
'altList': JSON.stringify(altList)
}, function (res) {
hideWaiting()
console.log(res)
var imgage = new Array()
for (var i = 0; i < res.image.length; i++) {
imgage.push(res.image[i])
}
console.log(imgage)
size = imgage.length
$("#graph4").html("<div style='text-align: center'><img style='height: 400px;width: 600px' src='http://210.77.68.250:8004/static/image/N2/" + res.t + "/nrlmsise00_N2.gif'></div>")
})
$.getJSON('/create/gif/O2/', {
'yearList': JSON.stringify(yearList),
'monthList': JSON.stringify(monthList),
'dayList': JSON.stringify(dayList),
'lonList': JSON.stringify(lonList),
'latList': JSON.stringify(latList),
'altList': JSON.stringify(altList)
}, function (res) {
hideWaiting()
console.log(res)
var imgage = new Array()
for (var i = 0; i < res.image.length; i++) {
imgage.push(res.image[i])
}
console.log(imgage)
size = imgage.length
$("#graph5").html("<div style='text-align: center'><img style='height: 400px;width: 600px' src='http://210.77.68.250:8004/static/image/O2/" + res.t + "/nrlmsise00_O2.gif'></div>")
})
$.getJSON('/create/gif/Ar/', {
'yearList': JSON.stringify(yearList),
'monthList': JSON.stringify(monthList),
'dayList': JSON.stringify(dayList),
'lonList': JSON.stringify(lonList),
'latList': JSON.stringify(latList),
'altList': JSON.stringify(altList)
}, function (res) {
hideWaiting()
console.log(res)
var imgage = new Array()
for (var i = 0; i < res.image.length; i++) {
imgage.push(res.image[i])
}
console.log(imgage)
size = imgage.length
$("#graph6").html("<div style='text-align: center'><img style='height: 400px;width: 600px' src='http://210.77.68.250:8004/static/image/Ar/" + res.t + "/nrlmsise00_Ar.gif'></div>")
})
$.getJSON('/create/gif/rho/', {
'yearList': JSON.stringify(yearList),
'monthList': JSON.stringify(monthList),
'dayList': JSON.stringify(dayList),
'lonList': JSON.stringify(lonList),
'latList': JSON.stringify(latList),
'altList': JSON.stringify(altList)
}, function (res) {
hideWaiting()
console.log(res)
var imgage = new Array()
for (var i = 0; i < res.image.length; i++) {
imgage.push(res.image[i])
}
console.log(imgage)
size = imgage.length
$("#graph7").html("<div style='text-align: center'><img style='height: 400px;width: 600px' src='http://210.77.68.250:8004/static/image/rho/" + res.t + "/nrlmsise00_rho.gif'></div>")
})
$.getJSON('/create/gif/Texo/', {
'yearList': JSON.stringify(yearList),
'monthList': JSON.stringify(monthList),
'dayList': JSON.stringify(dayList),
'lonList': JSON.stringify(lonList),
'latList': JSON.stringify(latList),
'altList': JSON.stringify(altList)
}, function (res) {
hideWaiting()
console.log(res)
var imgage = new Array()
for (var i = 0; i < res.image.length; i++) {
imgage.push(res.image[i])
}
console.log(imgage)
size = imgage.length
$("#graph8").html("<div style='text-align: center'><img style='height: 400px;width: 600px' src='http://210.77.68.250:8004/static/image/Texo/" + res.t + "/nrlmsise00_Texo.gif'></div>")
})
$.getJSON('/create/gif/Talt/', {
'yearList': JSON.stringify(yearList),
'monthList': JSON.stringify(monthList),
'dayList': JSON.stringify(dayList),
'lonList': JSON.stringify(lonList),
'latList': JSON.stringify(latList),
'altList': JSON.stringify(altList)
}, function (res) {
hideWaiting()
console.log(res)
var imgage = new Array()
for (var i = 0; i < res.image.length; i++) {
imgage.push(res.image[i])
}
console.log(imgage)
size = imgage.length
$("#graph9").html("<div style='text-align: center'><img style='height: 400px;width: 600px' src='http://210.77.68.250:8004/static/image/Talt/" + res.t + "/nrlmsise00_Talt.gif'></div>")
})
$.getJSON('/create/gif/lst/', {
'yearList': JSON.stringify(yearList),
'monthList': JSON.stringify(monthList),
'dayList': JSON.stringify(dayList),
'lonList': JSON.stringify(lonList),
'latList': JSON.stringify(latList),
'altList': JSON.stringify(altList)
}, function (res) {
hideWaiting()
console.log(res)
var imgage = new Array()
for (var i = 0; i < res.image.length; i++) {
imgage.push(res.image[i])
}
console.log(imgage)
size = imgage.length
$("#graph10").html("<div style='text-align: center'><img style='height: 400px;width: 600px' src='http://210.77.68.250:8004/static/image/lst/" + res.t + "/nrlmsise00_lst.gif'></div>")
})
$.getJSON('/create/gif/Ap/', {
'yearList': JSON.stringify(yearList),
'monthList': JSON.stringify(monthList),
'dayList': JSON.stringify(dayList),
'lonList': JSON.stringify(lonList),
'latList': JSON.stringify(latList),
'altList': JSON.stringify(altList)
}, function (res) {
hideWaiting()
console.log(res)
var imgage = new Array()
for (var i = 0; i < res.image.length; i++) {
imgage.push(res.image[i])
}
console.log(imgage)
size = imgage.length
$("#graph11").html("<div style='text-align: center'><img style='height: 400px;width: 600px' src='http://210.77.68.250:8004/static/image/Ap/" + res.t + "/nrlmsise00_Ap.gif'></div>")
})
$.getJSON('/create/gif/f107/', {
'yearList': JSON.stringify(yearList),
'monthList': JSON.stringify(monthList),
'dayList': JSON.stringify(dayList),
'lonList': JSON.stringify(lonList),
'latList': JSON.stringify(latList),
'altList': JSON.stringify(altList)
}, function (res) {
hideWaiting()
console.log(res)
var imgage = new Array()
for (var i = 0; i < res.image.length; i++) {
imgage.push(res.image[i])
}
console.log(imgage)
size = imgage.length
$("#graph12").html("<div style='text-align: center'><img style='height: 400px;width: 600px' src='http://210.77.68.250:8004/static/image/f107/" + res.t + "/nrlmsise00_f107.gif'></div>")
})
$.getJSON('/create/gif/f107a/', {
'yearList': JSON.stringify(yearList),
'monthList': JSON.stringify(monthList),
'dayList': JSON.stringify(dayList),
'lonList': JSON.stringify(lonList),
'latList': JSON.stringify(latList),
'altList': JSON.stringify(altList)
}, function (res) {
hideWaiting()
console.log(res)
var imgage = new Array()
for (var i = 0; i < res.image.length; i++) {
imgage.push(res.image[i])
}
console.log(imgage)
size = imgage.length
$("#graph13").html("<div style='text-align: center'><img style='height: 400px;width: 600px' src='http://210.77.68.250:8004/static/image/f107a/" + res.t + "/nrlmsise00_f107a.gif'></div>")
})
}
}
function createGif() {
$("#menu_element").show()
$("#graph1").hide()
$("#graph2").show()
$("#graph3").hide()
$("#graph4").hide()
$("#graph5").hide()
$("#graph6").hide()
$("#graph7").hide()
$("#graph8").hide()
$("#graph9").hide()
$("#graph10").hide()
$("#graph11").hide()
$("#graph12").hide()
$("#graph13").hide()
}
function createQuxian() {
$("#menu_element").hide()
$("#graph1").show()
$("#graph2").hide()
$("#graph3").hide()
$("#graph4").hide()
$("#graph5").hide()
$("#graph6").hide()
$("#graph7").hide()
$("#graph8").hide()
$("#graph9").hide()
$("#graph10").hide()
$("#graph11").hide()
$("#graph12").hide()
$("#graph13").hide()
}
function createGifHe() {
$("#graph1").hide()
$("#graph2").show()
$("#graph3").hide()
$("#graph4").hide()
$("#graph5").hide()
$("#graph6").hide()
$("#graph7").hide()
$("#graph8").hide()
$("#graph9").hide()
$("#graph10").hide()
$("#graph11").hide()
$("#graph12").hide()
$("#graph13").hide()
}
function createGifO() {
$("#graph1").hide()
$("#graph2").hide()
$("#graph3").show()
$("#graph4").hide()
$("#graph5").hide()
$("#graph6").hide()
$("#graph7").hide()
$("#graph8").hide()
$("#graph9").hide()
$("#graph10").hide()
$("#graph11").hide()
$("#graph12").hide()
$("#graph13").hide()
}
function createGifN2() {
$("#graph1").hide()
$("#graph2").hide()
$("#graph3").hide()
$("#graph4").show()
$("#graph5").hide()
$("#graph6").hide()
$("#graph7").hide()
$("#graph8").hide()
$("#graph9").hide()
$("#graph10").hide()
$("#graph11").hide()
$("#graph12").hide()
$("#graph13").hide()
}
function createGifO2() {
$("#graph1").hide()
$("#graph2").hide()
$("#graph3").hide()
$("#graph4").hide()
$("#graph5").show()
$("#graph6").hide()
$("#graph7").hide()
$("#graph8").hide()
$("#graph9").hide()
$("#graph10").hide()
$("#graph11").hide()
$("#graph12").hide()
$("#graph13").hide()
}
function createGifAr() {
$("#graph1").hide()
$("#graph2").hide()
$("#graph3").hide()
$("#graph4").hide()
$("#graph5").hide()
$("#graph6").show()
$("#graph7").hide()
$("#graph8").hide()
$("#graph9").hide()
$("#graph10").hide()
$("#graph11").hide()
$("#graph12").hide()
$("#graph13").hide()
}
function createGifrho() {
$("#graph1").hide()
$("#graph2").hide()
$("#graph3").hide()
$("#graph4").hide()
$("#graph5").hide()
$("#graph6").hide()
$("#graph7").show()
$("#graph8").hide()
$("#graph9").hide()
$("#graph10").hide()
$("#graph11").hide()
$("#graph12").hide()
$("#graph13").hide()
}
function createGifTexo() {
$("#graph1").hide()
$("#graph2").hide()
$("#graph3").hide()
$("#graph4").hide()
$("#graph5").hide()
$("#graph6").hide()
$("#graph7").hide()
$("#graph8").show()
$("#graph9").hide()
$("#graph10").hide()
$("#graph11").hide()
$("#graph12").hide()
$("#graph13").hide()
}
function createGifTalt() {
$("#graph1").hide()
$("#graph2").hide()
$("#graph3").hide()
$("#graph4").hide()
$("#graph5").hide()
$("#graph6").hide()
$("#graph7").hide()
$("#graph8").hide()
$("#graph9").show()
$("#graph10").hide()
$("#graph11").hide()
$("#graph12").hide()
$("#graph13").hide()
}
function createGiflst() {
$("#graph1").hide()
$("#graph2").hide()
$("#graph3").hide()
$("#graph4").hide()
$("#graph5").hide()
$("#graph6").hide()
$("#graph7").hide()
$("#graph8").hide()
$("#graph9").hide()
$("#graph10").show()
$("#graph11").hide()
$("#graph12").hide()
$("#graph13").hide()
}
function createGifAp() {
$("#graph1").hide()
$("#graph2").hide()
$("#graph3").hide()
$("#graph4").hide()
$("#graph5").hide()
$("#graph6").hide()
$("#graph7").hide()
$("#graph8").hide()
$("#graph9").hide()
$("#graph10").hide()
$("#graph11").show()
$("#graph12").hide()
$("#graph13").hide()
}
function createGiff107() {
$("#graph1").hide()
$("#graph2").hide()
$("#graph3").hide()
$("#graph4").hide()
$("#graph5").hide()
$("#graph6").hide()
$("#graph7").hide()
$("#graph8").hide()
$("#graph9").hide()
$("#graph10").hide()
$("#graph11").hide()
$("#graph12").show()
$("#graph13").hide()
}
function createGiff107a() {
$("#graph1").hide()
$("#graph2").hide()
$("#graph3").hide()
$("#graph4").hide()
$("#graph5").hide()
$("#graph6").hide()
$("#graph7").hide()
$("#graph8").hide()
$("#graph9").hide()
$("#graph10").hide()
$("#graph11").hide()
$("#graph12").hide()
$("#graph13").show()
}
</script>
{% endblock %}

View File

@ -12,5 +12,16 @@ urlpatterns = [
path('msise/flat/string/',views.msise_flat_string,name='msise-flat-string'),
path('runing/model/',views.runing_model,name = 'runing-model'),
path('runing/model/alts/',views.runing_model_alts,name = 'runing-model-alts'),
path('create/gif/',views.create_gif,name = 'create-gif'),
path('create/gif/He/',views.create_gif_He,name = 'create-gif'),
path('create/gif/O/',views.create_gif_O,name = 'create-gif'),
path('create/gif/N2/',views.create_gif_N2,name = 'create-gif'),
path('create/gif/O2/',views.create_gif_O2,name = 'create-gif'),
path('create/gif/Ar/',views.create_gif_Ar,name = 'create-gif'),
path('create/gif/rho/',views.create_gif_rho,name = 'create-gif'),
path('create/gif/Texo/',views.create_gif_Texo,name = 'create-gif'),
path('create/gif/Talt/',views.create_gif_Talt,name = 'create-gif'),
path('create/gif/lst/',views.create_gif_lst,name = 'create-gif'),
path('create/gif/Ap/',views.create_gif_Ap,name = 'create-gif'),
path('create/gif/Ap/',views.create_gif_Ap,name = 'create-gif'),
path('create/gif/f107a/',views.create_gif_f107a,name = 'create-gif'),
]

View File

@ -429,7 +429,7 @@ def runing_model_alts(request):
return render(request, 'dashboard/xulie.html')
def create_gif(request):
def create_gif_He(request):
yearList = request.GET.get('yearList')
monthList = request.GET.get('monthList')
dayList = request.GET.get('dayList')
@ -492,24 +492,21 @@ def create_gif(request):
# f = '/static/image/%d.png' % (counter)
os.popen('mkdir /var/www/p3/atmosphericinversion/static/image/%s' % (t))
f = '/var/www/p3/atmosphericinversion/static/image/%s/%d.png' % (t,counter)
os.popen('mkdir /var/www/p3/atmosphericinversion/static/image/He/%s' % (t))
f = '/var/www/p3/atmosphericinversion/static/image/He/%s/%d.png' % (t,counter)
fig.savefig(f, dpi=200,bbox_inches="tight")
fs.append(f)
gif_name = 'nrlmsise00.gif'
gif_name = 'nrlmsise00_He.gif'
# path_dest = '/static/image/'
path_dest = '/var/www/p3/atmosphericinversion/static/image/%s/'%(t)
path_dest = '/var/www/p3/atmosphericinversion/static/image/He/%s/'%(t)
duration = 0.9
frames = []
for image_name in fs:
print(image_name)
frames.append(imageio.imread(image_name))
imageio.mimsave(path_dest + gif_name, frames, 'GIF', duration=duration)
lo = lons
la = lats
al = alts
return HttpResponse(json.dumps({
"image": fs,
'message':message,
@ -517,3 +514,935 @@ def create_gif(request):
}))
def create_gif_O(request):
yearList = request.GET.get('yearList')
monthList = request.GET.get('monthList')
dayList = request.GET.get('dayList')
lonList = request.GET.get('lonList')
latList = request.GET.get('latList')
altList = request.GET.get('altList')
dt = None
lons = []
lats = []
alts = []
dts = []
message = None
if yearList:
for i, value in enumerate(yearList[1:-1].split(',')):
year = int(value.split('"')[1])
month = int(monthList[1:-1].split(',')[i].split('"')[1])
print(month)
d = datetime.datetime(int(year), int(month), 1, 0, 0, 0)
dts.append(d)
alts.append(int(altList[1:-1].split(',')[i].split('"')[1]))
if ';' in lonList[1:-1].split(',')[i].split('"')[1]:
lons = np.arange(int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[0]), int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[1]), int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[2]))
else:
message = '请输入正确的数据格式'
if ';' in latList[1:-1].split(',')[i].split('"')[1]:
lats = np.arange(int(latList[1:-1].split(',')[i].split('"')[1].split(';')[0]),
int(latList[1:-1].split(',')[i].split('"')[1].split(';')[1]),
int(latList[1:-1].split(',')[i].split('"')[1].split(';')[2]))
else:
message = '请输入正确的数据格式'
fig = plt.figure() # (figsize=(16, 8))
fs = []
t = int(time.time())
for counter, dt in enumerate(dts):
print(dt, alts, lats, lons)
# broadcasting is done internally
ds = msise_4d(dt, alts, lats, lons)
# 创建一个没有 axes 的 figure
# fig.suptitle('Model nrlmsise00') # 添加标题以便我们辨别
lats = ds.lat.data
lons = ds.lon.data
x, y = np.meshgrid(lons, lats)
data = ds.O[0, 0, :, :].data
str_d = datetime.datetime.strftime(dt, '%Y-%m-%d')
plt.title(u'空间分布图(O)' + str_d, fontproperties='Microsoft YaHei')
plt.xlabel(u'经度(E)', fontproperties='Microsoft YaHei')
plt.ylabel(u'纬度(N)', fontproperties='Microsoft YaHei')
plt.legend()
plt.contourf(x, y, data, cmap=plt.cm.Spectral, alpha=0.8)
plt.pause(0.3)
# f = '/static/image/%d.png' % (counter)
os.popen('mkdir /var/www/p3/atmosphericinversion/static/image/O/%s' % (t))
f = '/var/www/p3/atmosphericinversion/static/image/O/%s/%d.png' % (t,counter)
fig.savefig(f, dpi=200,bbox_inches="tight")
fs.append(f)
gif_name = 'nrlmsise00_O.gif'
# path_dest = '/static/image/'
path_dest = '/var/www/p3/atmosphericinversion/static/image/O/%s/'%(t)
duration = 0.9
frames = []
for image_name in fs:
print(image_name)
frames.append(imageio.imread(image_name))
imageio.mimsave(path_dest + gif_name, frames, 'GIF', duration=duration)
return HttpResponse(json.dumps({
"image": fs,
'message':message,
't':t,
}))
def create_gif_N2(request):
yearList = request.GET.get('yearList')
monthList = request.GET.get('monthList')
dayList = request.GET.get('dayList')
lonList = request.GET.get('lonList')
latList = request.GET.get('latList')
altList = request.GET.get('altList')
dt = None
lons = []
lats = []
alts = []
dts = []
message = None
if yearList:
for i, value in enumerate(yearList[1:-1].split(',')):
year = int(value.split('"')[1])
month = int(monthList[1:-1].split(',')[i].split('"')[1])
print(month)
d = datetime.datetime(int(year), int(month), 1, 0, 0, 0)
dts.append(d)
alts.append(int(altList[1:-1].split(',')[i].split('"')[1]))
if ';' in lonList[1:-1].split(',')[i].split('"')[1]:
lons = np.arange(int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[0]), int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[1]), int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[2]))
else:
message = '请输入正确的数据格式'
if ';' in latList[1:-1].split(',')[i].split('"')[1]:
lats = np.arange(int(latList[1:-1].split(',')[i].split('"')[1].split(';')[0]),
int(latList[1:-1].split(',')[i].split('"')[1].split(';')[1]),
int(latList[1:-1].split(',')[i].split('"')[1].split(';')[2]))
else:
message = '请输入正确的数据格式'
fig = plt.figure() # (figsize=(16, 8))
fs = []
t = int(time.time())
for counter, dt in enumerate(dts):
print(dt, alts, lats, lons)
# broadcasting is done internally
ds = msise_4d(dt, alts, lats, lons)
# 创建一个没有 axes 的 figure
# fig.suptitle('Model nrlmsise00') # 添加标题以便我们辨别
lats = ds.lat.data
lons = ds.lon.data
x, y = np.meshgrid(lons, lats)
data = ds.N2[0, 0, :, :].data
str_d = datetime.datetime.strftime(dt, '%Y-%m-%d')
plt.title(u'空间分布图(N2)' + str_d, fontproperties='Microsoft YaHei')
plt.xlabel(u'经度(E)', fontproperties='Microsoft YaHei')
plt.ylabel(u'纬度(N)', fontproperties='Microsoft YaHei')
plt.legend()
plt.contourf(x, y, data, cmap=plt.cm.Spectral, alpha=0.8)
plt.pause(0.3)
# f = '/static/image/%d.png' % (counter)
os.popen('mkdir /var/www/p3/atmosphericinversion/static/image/N2/%s' % (t))
f = '/var/www/p3/atmosphericinversion/static/image/N2/%s/%d.png' % (t,counter)
fig.savefig(f, dpi=200,bbox_inches="tight")
fs.append(f)
gif_name = 'nrlmsise00_N2.gif'
# path_dest = '/static/image/'
path_dest = '/var/www/p3/atmosphericinversion/static/image/N2/%s/'%(t)
duration = 0.9
frames = []
for image_name in fs:
print(image_name)
frames.append(imageio.imread(image_name))
imageio.mimsave(path_dest + gif_name, frames, 'GIF', duration=duration)
return HttpResponse(json.dumps({
"image": fs,
'message':message,
't':t,
}))
def create_gif_O2(request):
yearList = request.GET.get('yearList')
monthList = request.GET.get('monthList')
dayList = request.GET.get('dayList')
lonList = request.GET.get('lonList')
latList = request.GET.get('latList')
altList = request.GET.get('altList')
dt = None
lons = []
lats = []
alts = []
dts = []
message = None
if yearList:
for i, value in enumerate(yearList[1:-1].split(',')):
year = int(value.split('"')[1])
month = int(monthList[1:-1].split(',')[i].split('"')[1])
print(month)
d = datetime.datetime(int(year), int(month), 1, 0, 0, 0)
dts.append(d)
alts.append(int(altList[1:-1].split(',')[i].split('"')[1]))
if ';' in lonList[1:-1].split(',')[i].split('"')[1]:
lons = np.arange(int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[0]), int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[1]), int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[2]))
else:
message = '请输入正确的数据格式'
if ';' in latList[1:-1].split(',')[i].split('"')[1]:
lats = np.arange(int(latList[1:-1].split(',')[i].split('"')[1].split(';')[0]),
int(latList[1:-1].split(',')[i].split('"')[1].split(';')[1]),
int(latList[1:-1].split(',')[i].split('"')[1].split(';')[2]))
else:
message = '请输入正确的数据格式'
fig = plt.figure() # (figsize=(16, 8))
fs = []
t = int(time.time())
for counter, dt in enumerate(dts):
print(dt, alts, lats, lons)
# broadcasting is done internally
ds = msise_4d(dt, alts, lats, lons)
# 创建一个没有 axes 的 figure
# fig.suptitle('Model nrlmsise00') # 添加标题以便我们辨别
lats = ds.lat.data
lons = ds.lon.data
x, y = np.meshgrid(lons, lats)
data = ds.O2[0, 0, :, :].data
str_d = datetime.datetime.strftime(dt, '%Y-%m-%d')
plt.title(u'空间分布图(O2)' + str_d, fontproperties='Microsoft YaHei')
plt.xlabel(u'经度(E)', fontproperties='Microsoft YaHei')
plt.ylabel(u'纬度(N)', fontproperties='Microsoft YaHei')
plt.legend()
plt.contourf(x, y, data, cmap=plt.cm.Spectral, alpha=0.8)
plt.pause(0.3)
# f = '/static/image/%d.png' % (counter)
os.popen('mkdir /var/www/p3/atmosphericinversion/static/image/O2/%s' % (t))
f = '/var/www/p3/atmosphericinversion/static/image/O2/%s/%d.png' % (t,counter)
fig.savefig(f, dpi=200,bbox_inches="tight")
fs.append(f)
gif_name = 'nrlmsise00_O2.gif'
# path_dest = '/static/image/'
path_dest = '/var/www/p3/atmosphericinversion/static/image/O2/%s/'%(t)
duration = 0.9
frames = []
for image_name in fs:
print(image_name)
frames.append(imageio.imread(image_name))
imageio.mimsave(path_dest + gif_name, frames, 'GIF', duration=duration)
return HttpResponse(json.dumps({
"image": fs,
'message':message,
't':t,
}))
def create_gif_Ar(request):
yearList = request.GET.get('yearList')
monthList = request.GET.get('monthList')
dayList = request.GET.get('dayList')
lonList = request.GET.get('lonList')
latList = request.GET.get('latList')
altList = request.GET.get('altList')
dt = None
lons = []
lats = []
alts = []
dts = []
message = None
if yearList:
for i, value in enumerate(yearList[1:-1].split(',')):
year = int(value.split('"')[1])
month = int(monthList[1:-1].split(',')[i].split('"')[1])
print(month)
d = datetime.datetime(int(year), int(month), 1, 0, 0, 0)
dts.append(d)
alts.append(int(altList[1:-1].split(',')[i].split('"')[1]))
if ';' in lonList[1:-1].split(',')[i].split('"')[1]:
lons = np.arange(int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[0]), int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[1]), int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[2]))
else:
message = '请输入正确的数据格式'
if ';' in latList[1:-1].split(',')[i].split('"')[1]:
lats = np.arange(int(latList[1:-1].split(',')[i].split('"')[1].split(';')[0]),
int(latList[1:-1].split(',')[i].split('"')[1].split(';')[1]),
int(latList[1:-1].split(',')[i].split('"')[1].split(';')[2]))
else:
message = '请输入正确的数据格式'
fig = plt.figure() # (figsize=(16, 8))
fs = []
t = int(time.time())
for counter, dt in enumerate(dts):
print(dt, alts, lats, lons)
# broadcasting is done internally
ds = msise_4d(dt, alts, lats, lons)
# 创建一个没有 axes 的 figure
# fig.suptitle('Model nrlmsise00') # 添加标题以便我们辨别
lats = ds.lat.data
lons = ds.lon.data
x, y = np.meshgrid(lons, lats)
data = ds.Ar[0, 0, :, :].data
str_d = datetime.datetime.strftime(dt, '%Y-%m-%d')
plt.title(u'空间分布图(Ar)' + str_d, fontproperties='Microsoft YaHei')
plt.xlabel(u'经度(E)', fontproperties='Microsoft YaHei')
plt.ylabel(u'纬度(N)', fontproperties='Microsoft YaHei')
plt.legend()
plt.contourf(x, y, data, cmap=plt.cm.Spectral, alpha=0.8)
plt.pause(0.3)
# f = '/static/image/%d.png' % (counter)
os.popen('mkdir /var/www/p3/atmosphericinversion/static/image/Ar/%s' % (t))
f = '/var/www/p3/atmosphericinversion/static/image/Ar/%s/%d.png' % (t,counter)
fig.savefig(f, dpi=200,bbox_inches="tight")
fs.append(f)
gif_name = 'nrlmsise00_Ar.gif'
# path_dest = '/static/image/'
path_dest = '/var/www/p3/atmosphericinversion/static/image/Ar/%s/'%(t)
duration = 0.9
frames = []
for image_name in fs:
print(image_name)
frames.append(imageio.imread(image_name))
imageio.mimsave(path_dest + gif_name, frames, 'GIF', duration=duration)
return HttpResponse(json.dumps({
"image": fs,
'message':message,
't':t,
}))
def create_gif_rho(request):
yearList = request.GET.get('yearList')
monthList = request.GET.get('monthList')
dayList = request.GET.get('dayList')
lonList = request.GET.get('lonList')
latList = request.GET.get('latList')
altList = request.GET.get('altList')
dt = None
lons = []
lats = []
alts = []
dts = []
message = None
if yearList:
for i, value in enumerate(yearList[1:-1].split(',')):
year = int(value.split('"')[1])
month = int(monthList[1:-1].split(',')[i].split('"')[1])
print(month)
d = datetime.datetime(int(year), int(month), 1, 0, 0, 0)
dts.append(d)
alts.append(int(altList[1:-1].split(',')[i].split('"')[1]))
if ';' in lonList[1:-1].split(',')[i].split('"')[1]:
lons = np.arange(int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[0]), int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[1]), int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[2]))
else:
message = '请输入正确的数据格式'
if ';' in latList[1:-1].split(',')[i].split('"')[1]:
lats = np.arange(int(latList[1:-1].split(',')[i].split('"')[1].split(';')[0]),
int(latList[1:-1].split(',')[i].split('"')[1].split(';')[1]),
int(latList[1:-1].split(',')[i].split('"')[1].split(';')[2]))
else:
message = '请输入正确的数据格式'
fig = plt.figure() # (figsize=(16, 8))
fs = []
t = int(time.time())
for counter, dt in enumerate(dts):
print(dt, alts, lats, lons)
# broadcasting is done internally
ds = msise_4d(dt, alts, lats, lons)
# 创建一个没有 axes 的 figure
# fig.suptitle('Model nrlmsise00') # 添加标题以便我们辨别
lats = ds.lat.data
lons = ds.lon.data
x, y = np.meshgrid(lons, lats)
data = ds.rho[0, 0, :, :].data
str_d = datetime.datetime.strftime(dt, '%Y-%m-%d')
plt.title(u'空间分布图(rho)' + str_d, fontproperties='Microsoft YaHei')
plt.xlabel(u'经度(E)', fontproperties='Microsoft YaHei')
plt.ylabel(u'纬度(N)', fontproperties='Microsoft YaHei')
plt.legend()
plt.contourf(x, y, data, cmap=plt.cm.Spectral, alpha=0.8)
plt.pause(0.3)
# f = '/static/image/%d.png' % (counter)
os.popen('mkdir /var/www/p3/atmosphericinversion/static/image/rho/%s' % (t))
f = '/var/www/p3/atmosphericinversion/static/image/rho/%s/%d.png' % (t,counter)
fig.savefig(f, dpi=200,bbox_inches="tight")
fs.append(f)
gif_name = 'nrlmsise00_rho.gif'
# path_dest = '/static/image/'
path_dest = '/var/www/p3/atmosphericinversion/static/image/rho/%s/'%(t)
duration = 0.9
frames = []
for image_name in fs:
print(image_name)
frames.append(imageio.imread(image_name))
imageio.mimsave(path_dest + gif_name, frames, 'GIF', duration=duration)
return HttpResponse(json.dumps({
"image": fs,
'message':message,
't':t,
}))
def create_gif_Texo(request):
yearList = request.GET.get('yearList')
monthList = request.GET.get('monthList')
dayList = request.GET.get('dayList')
lonList = request.GET.get('lonList')
latList = request.GET.get('latList')
altList = request.GET.get('altList')
dt = None
lons = []
lats = []
alts = []
dts = []
message = None
if yearList:
for i, value in enumerate(yearList[1:-1].split(',')):
year = int(value.split('"')[1])
month = int(monthList[1:-1].split(',')[i].split('"')[1])
print(month)
d = datetime.datetime(int(year), int(month), 1, 0, 0, 0)
dts.append(d)
alts.append(int(altList[1:-1].split(',')[i].split('"')[1]))
if ';' in lonList[1:-1].split(',')[i].split('"')[1]:
lons = np.arange(int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[0]), int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[1]), int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[2]))
else:
message = '请输入正确的数据格式'
if ';' in latList[1:-1].split(',')[i].split('"')[1]:
lats = np.arange(int(latList[1:-1].split(',')[i].split('"')[1].split(';')[0]),
int(latList[1:-1].split(',')[i].split('"')[1].split(';')[1]),
int(latList[1:-1].split(',')[i].split('"')[1].split(';')[2]))
else:
message = '请输入正确的数据格式'
fig = plt.figure() # (figsize=(16, 8))
fs = []
t = int(time.time())
for counter, dt in enumerate(dts):
print(dt, alts, lats, lons)
# broadcasting is done internally
ds = msise_4d(dt, alts, lats, lons)
# 创建一个没有 axes 的 figure
# fig.suptitle('Model nrlmsise00') # 添加标题以便我们辨别
lats = ds.lat.data
lons = ds.lon.data
x, y = np.meshgrid(lons, lats)
data = ds.Texo[0, 0, :, :].data
str_d = datetime.datetime.strftime(dt, '%Y-%m-%d')
plt.title(u'空间分布图(Texo)' + str_d, fontproperties='Microsoft YaHei')
plt.xlabel(u'经度(E)', fontproperties='Microsoft YaHei')
plt.ylabel(u'纬度(N)', fontproperties='Microsoft YaHei')
plt.legend()
plt.contourf(x, y, data, cmap=plt.cm.Spectral, alpha=0.8)
plt.pause(0.3)
# f = '/static/image/%d.png' % (counter)
os.popen('mkdir /var/www/p3/atmosphericinversion/static/image/Texo/%s' % (t))
f = '/var/www/p3/atmosphericinversion/static/image/Texo/%s/%d.png' % (t,counter)
fig.savefig(f, dpi=200,bbox_inches="tight")
fs.append(f)
gif_name = 'nrlmsise00_Texo.gif'
# path_dest = '/static/image/'
path_dest = '/var/www/p3/atmosphericinversion/static/image/Texo/%s/'%(t)
duration = 0.9
frames = []
for image_name in fs:
print(image_name)
frames.append(imageio.imread(image_name))
imageio.mimsave(path_dest + gif_name, frames, 'GIF', duration=duration)
return HttpResponse(json.dumps({
"image": fs,
'message':message,
't':t,
}))
def create_gif_Talt(request):
yearList = request.GET.get('yearList')
monthList = request.GET.get('monthList')
dayList = request.GET.get('dayList')
lonList = request.GET.get('lonList')
latList = request.GET.get('latList')
altList = request.GET.get('altList')
dt = None
lons = []
lats = []
alts = []
dts = []
message = None
if yearList:
for i, value in enumerate(yearList[1:-1].split(',')):
year = int(value.split('"')[1])
month = int(monthList[1:-1].split(',')[i].split('"')[1])
print(month)
d = datetime.datetime(int(year), int(month), 1, 0, 0, 0)
dts.append(d)
alts.append(int(altList[1:-1].split(',')[i].split('"')[1]))
if ';' in lonList[1:-1].split(',')[i].split('"')[1]:
lons = np.arange(int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[0]), int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[1]), int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[2]))
else:
message = '请输入正确的数据格式'
if ';' in latList[1:-1].split(',')[i].split('"')[1]:
lats = np.arange(int(latList[1:-1].split(',')[i].split('"')[1].split(';')[0]),
int(latList[1:-1].split(',')[i].split('"')[1].split(';')[1]),
int(latList[1:-1].split(',')[i].split('"')[1].split(';')[2]))
else:
message = '请输入正确的数据格式'
fig = plt.figure() # (figsize=(16, 8))
fs = []
t = int(time.time())
for counter, dt in enumerate(dts):
print(dt, alts, lats, lons)
# broadcasting is done internally
ds = msise_4d(dt, alts, lats, lons)
# 创建一个没有 axes 的 figure
# fig.suptitle('Model nrlmsise00') # 添加标题以便我们辨别
lats = ds.lat.data
lons = ds.lon.data
x, y = np.meshgrid(lons, lats)
data = ds.Talt[0, 0, :, :].data
str_d = datetime.datetime.strftime(dt, '%Y-%m-%d')
plt.title(u'空间分布图(Talt)' + str_d, fontproperties='Microsoft YaHei')
plt.xlabel(u'经度(E)', fontproperties='Microsoft YaHei')
plt.ylabel(u'纬度(N)', fontproperties='Microsoft YaHei')
plt.legend()
plt.contourf(x, y, data, cmap=plt.cm.Spectral, alpha=0.8)
plt.pause(0.3)
# f = '/static/image/%d.png' % (counter)
os.popen('mkdir /var/www/p3/atmosphericinversion/static/image/Talt/%s' % (t))
f = '/var/www/p3/atmosphericinversion/static/image/Talt/%s/%d.png' % (t,counter)
fig.savefig(f, dpi=200,bbox_inches="tight")
fs.append(f)
gif_name = 'nrlmsise00_Talt.gif'
# path_dest = '/static/image/'
path_dest = '/var/www/p3/atmosphericinversion/static/image/Talt/%s/'%(t)
duration = 0.9
frames = []
for image_name in fs:
print(image_name)
frames.append(imageio.imread(image_name))
imageio.mimsave(path_dest + gif_name, frames, 'GIF', duration=duration)
return HttpResponse(json.dumps({
"image": fs,
'message':message,
't':t,
}))
def create_gif_lst(request):
yearList = request.GET.get('yearList')
monthList = request.GET.get('monthList')
dayList = request.GET.get('dayList')
lonList = request.GET.get('lonList')
latList = request.GET.get('latList')
altList = request.GET.get('altList')
dt = None
lons = []
lats = []
alts = []
dts = []
message = None
if yearList:
for i, value in enumerate(yearList[1:-1].split(',')):
year = int(value.split('"')[1])
month = int(monthList[1:-1].split(',')[i].split('"')[1])
print(month)
d = datetime.datetime(int(year), int(month), 1, 0, 0, 0)
dts.append(d)
alts.append(int(altList[1:-1].split(',')[i].split('"')[1]))
if ';' in lonList[1:-1].split(',')[i].split('"')[1]:
lons = np.arange(int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[0]), int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[1]), int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[2]))
else:
message = '请输入正确的数据格式'
if ';' in latList[1:-1].split(',')[i].split('"')[1]:
lats = np.arange(int(latList[1:-1].split(',')[i].split('"')[1].split(';')[0]),
int(latList[1:-1].split(',')[i].split('"')[1].split(';')[1]),
int(latList[1:-1].split(',')[i].split('"')[1].split(';')[2]))
else:
message = '请输入正确的数据格式'
fig = plt.figure() # (figsize=(16, 8))
fs = []
t = int(time.time())
for counter, dt in enumerate(dts):
print(dt, alts, lats, lons)
# broadcasting is done internally
ds = msise_4d(dt, alts, lats, lons)
# 创建一个没有 axes 的 figure
# fig.suptitle('Model nrlmsise00') # 添加标题以便我们辨别
lats = ds.lat.data
lons = ds.lon.data
x, y = np.meshgrid(lons, lats)
data = ds.lst[0, 0, :, :].data
str_d = datetime.datetime.strftime(dt, '%Y-%m-%d')
plt.title(u'空间分布图(lst)' + str_d, fontproperties='Microsoft YaHei')
plt.xlabel(u'经度(E)', fontproperties='Microsoft YaHei')
plt.ylabel(u'纬度(N)', fontproperties='Microsoft YaHei')
plt.legend()
plt.contourf(x, y, data, cmap=plt.cm.Spectral, alpha=0.8)
plt.pause(0.3)
# f = '/static/image/%d.png' % (counter)
os.popen('mkdir /var/www/p3/atmosphericinversion/static/image/lst/%s' % (t))
f = '/var/www/p3/atmosphericinversion/static/image/lst/%s/%d.png' % (t,counter)
fig.savefig(f, dpi=200,bbox_inches="tight")
fs.append(f)
gif_name = 'nrlmsise00_lst.gif'
# path_dest = '/static/image/'
path_dest = '/var/www/p3/atmosphericinversion/static/image/lst/%s/'%(t)
duration = 0.9
frames = []
for image_name in fs:
print(image_name)
frames.append(imageio.imread(image_name))
imageio.mimsave(path_dest + gif_name, frames, 'GIF', duration=duration)
return HttpResponse(json.dumps({
"image": fs,
'message':message,
't':t,
}))
def create_gif_Ap(request):
yearList = request.GET.get('yearList')
monthList = request.GET.get('monthList')
dayList = request.GET.get('dayList')
lonList = request.GET.get('lonList')
latList = request.GET.get('latList')
altList = request.GET.get('altList')
dt = None
lons = []
lats = []
alts = []
dts = []
message = None
if yearList:
for i, value in enumerate(yearList[1:-1].split(',')):
year = int(value.split('"')[1])
month = int(monthList[1:-1].split(',')[i].split('"')[1])
print(month)
d = datetime.datetime(int(year), int(month), 1, 0, 0, 0)
dts.append(d)
alts.append(int(altList[1:-1].split(',')[i].split('"')[1]))
if ';' in lonList[1:-1].split(',')[i].split('"')[1]:
lons = np.arange(int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[0]), int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[1]), int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[2]))
else:
message = '请输入正确的数据格式'
if ';' in latList[1:-1].split(',')[i].split('"')[1]:
lats = np.arange(int(latList[1:-1].split(',')[i].split('"')[1].split(';')[0]),
int(latList[1:-1].split(',')[i].split('"')[1].split(';')[1]),
int(latList[1:-1].split(',')[i].split('"')[1].split(';')[2]))
else:
message = '请输入正确的数据格式'
fig = plt.figure() # (figsize=(16, 8))
fs = []
t = int(time.time())
for counter, dt in enumerate(dts):
print(dt, alts, lats, lons)
# broadcasting is done internally
ds = msise_4d(dt, alts, lats, lons)
# 创建一个没有 axes 的 figure
# fig.suptitle('Model nrlmsise00') # 添加标题以便我们辨别
lats = ds.lat.data
lons = ds.lon.data
x, y = np.meshgrid(lons, lats)
data = ds.Ap[0, 0, :, :].data
str_d = datetime.datetime.strftime(dt, '%Y-%m-%d')
plt.title(u'空间分布图(Ap)' + str_d, fontproperties='Microsoft YaHei')
plt.xlabel(u'经度(E)', fontproperties='Microsoft YaHei')
plt.ylabel(u'纬度(N)', fontproperties='Microsoft YaHei')
plt.legend()
plt.contourf(x, y, data, cmap=plt.cm.Spectral, alpha=0.8)
plt.pause(0.3)
# f = '/static/image/%d.png' % (counter)
os.popen('mkdir /var/www/p3/atmosphericinversion/static/image/Ap/%s' % (t))
f = '/var/www/p3/atmosphericinversion/static/image/Ap/%s/%d.png' % (t,counter)
fig.savefig(f, dpi=200,bbox_inches="tight")
fs.append(f)
gif_name = 'nrlmsise00_Ap.gif'
# path_dest = '/static/image/'
path_dest = '/var/www/p3/atmosphericinversion/static/image/Ap/%s/'%(t)
duration = 0.9
frames = []
for image_name in fs:
print(image_name)
frames.append(imageio.imread(image_name))
imageio.mimsave(path_dest + gif_name, frames, 'GIF', duration=duration)
return HttpResponse(json.dumps({
"image": fs,
'message':message,
't':t,
}))
def create_gif_f107(request):
yearList = request.GET.get('yearList')
monthList = request.GET.get('monthList')
dayList = request.GET.get('dayList')
lonList = request.GET.get('lonList')
latList = request.GET.get('latList')
altList = request.GET.get('altList')
dt = None
lons = []
lats = []
alts = []
dts = []
message = None
if yearList:
for i, value in enumerate(yearList[1:-1].split(',')):
year = int(value.split('"')[1])
month = int(monthList[1:-1].split(',')[i].split('"')[1])
print(month)
d = datetime.datetime(int(year), int(month), 1, 0, 0, 0)
dts.append(d)
alts.append(int(altList[1:-1].split(',')[i].split('"')[1]))
if ';' in lonList[1:-1].split(',')[i].split('"')[1]:
lons = np.arange(int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[0]), int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[1]), int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[2]))
else:
message = '请输入正确的数据格式'
if ';' in latList[1:-1].split(',')[i].split('"')[1]:
lats = np.arange(int(latList[1:-1].split(',')[i].split('"')[1].split(';')[0]),
int(latList[1:-1].split(',')[i].split('"')[1].split(';')[1]),
int(latList[1:-1].split(',')[i].split('"')[1].split(';')[2]))
else:
message = '请输入正确的数据格式'
fig = plt.figure() # (figsize=(16, 8))
fs = []
t = int(time.time())
for counter, dt in enumerate(dts):
print(dt, alts, lats, lons)
# broadcasting is done internally
ds = msise_4d(dt, alts, lats, lons)
# 创建一个没有 axes 的 figure
# fig.suptitle('Model nrlmsise00') # 添加标题以便我们辨别
lats = ds.lat.data
lons = ds.lon.data
x, y = np.meshgrid(lons, lats)
data = ds.f107[0, 0, :, :].data
str_d = datetime.datetime.strftime(dt, '%Y-%m-%d')
plt.title(u'空间分布图(f107)' + str_d, fontproperties='Microsoft YaHei')
plt.xlabel(u'经度(E)', fontproperties='Microsoft YaHei')
plt.ylabel(u'纬度(N)', fontproperties='Microsoft YaHei')
plt.legend()
plt.contourf(x, y, data, cmap=plt.cm.Spectral, alpha=0.8)
plt.pause(0.3)
# f = '/static/image/%d.png' % (counter)
os.popen('mkdir /var/www/p3/atmosphericinversion/static/image/f107/%s' % (t))
f = '/var/www/p3/atmosphericinversion/static/image/f107/%s/%d.png' % (t,counter)
fig.savefig(f, dpi=200,bbox_inches="tight")
fs.append(f)
gif_name = 'nrlmsise00_f107.gif'
# path_dest = '/static/image/'
path_dest = '/var/www/p3/atmosphericinversion/static/image/f107/%s/'%(t)
duration = 0.9
frames = []
for image_name in fs:
print(image_name)
frames.append(imageio.imread(image_name))
imageio.mimsave(path_dest + gif_name, frames, 'GIF', duration=duration)
return HttpResponse(json.dumps({
"image": fs,
'message':message,
't':t,
}))
def create_gif_f107a(request):
yearList = request.GET.get('yearList')
monthList = request.GET.get('monthList')
dayList = request.GET.get('dayList')
lonList = request.GET.get('lonList')
latList = request.GET.get('latList')
altList = request.GET.get('altList')
dt = None
lons = []
lats = []
alts = []
dts = []
message = None
if yearList:
for i, value in enumerate(yearList[1:-1].split(',')):
year = int(value.split('"')[1])
month = int(monthList[1:-1].split(',')[i].split('"')[1])
print(month)
d = datetime.datetime(int(year), int(month), 1, 0, 0, 0)
dts.append(d)
alts.append(int(altList[1:-1].split(',')[i].split('"')[1]))
if ';' in lonList[1:-1].split(',')[i].split('"')[1]:
lons = np.arange(int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[0]), int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[1]), int(lonList[1:-1].split(',')[i].split('"')[1].split(';')[2]))
else:
message = '请输入正确的数据格式'
if ';' in latList[1:-1].split(',')[i].split('"')[1]:
lats = np.arange(int(latList[1:-1].split(',')[i].split('"')[1].split(';')[0]),
int(latList[1:-1].split(',')[i].split('"')[1].split(';')[1]),
int(latList[1:-1].split(',')[i].split('"')[1].split(';')[2]))
else:
message = '请输入正确的数据格式'
fig = plt.figure() # (figsize=(16, 8))
fs = []
t = int(time.time())
for counter, dt in enumerate(dts):
print(dt, alts, lats, lons)
# broadcasting is done internally
ds = msise_4d(dt, alts, lats, lons)
# 创建一个没有 axes 的 figure
# fig.suptitle('Model nrlmsise00') # 添加标题以便我们辨别
lats = ds.lat.data
lons = ds.lon.data
x, y = np.meshgrid(lons, lats)
data = ds.f107a[0, 0, :, :].data
str_d = datetime.datetime.strftime(dt, '%Y-%m-%d')
plt.title(u'空间分布图(f107a)' + str_d, fontproperties='Microsoft YaHei')
plt.xlabel(u'经度(E)', fontproperties='Microsoft YaHei')
plt.ylabel(u'纬度(N)', fontproperties='Microsoft YaHei')
plt.legend()
plt.contourf(x, y, data, cmap=plt.cm.Spectral, alpha=0.8)
plt.pause(0.3)
# f = '/static/image/%d.png' % (counter)
os.popen('mkdir /var/www/p3/atmosphericinversion/static/image/f107a/%s' % (t))
f = '/var/www/p3/atmosphericinversion/static/image/f107a/%s/%d.png' % (t,counter)
fig.savefig(f, dpi=200,bbox_inches="tight")
fs.append(f)
gif_name = 'nrlmsise00_f107a.gif'
# path_dest = '/static/image/'
path_dest = '/var/www/p3/atmosphericinversion/static/image/f107a/%s/'%(t)
duration = 0.9
frames = []
for image_name in fs:
print(image_name)
frames.append(imageio.imread(image_name))
imageio.mimsave(path_dest + gif_name, frames, 'GIF', duration=duration)
return HttpResponse(json.dumps({
"image": fs,
'message':message,
't':t,
}))