92 lines
2.2 KiB
Python
92 lines
2.2 KiB
Python
#!/usr/bin/env python
|
||
"""
|
||
НАЗВАНИЕ:
|
||
|
||
plot.py
|
||
|
||
|
||
НАЗНАЧЕНИЕ:
|
||
|
||
Простой скрипт для отрисовки файла, выгруженного с СРГ L2 монитора https://monitor.srg.cosmos.ru/
|
||
|
||
ВЫЗОВ:
|
||
|
||
conda activate
|
||
./plot.py
|
||
|
||
|
||
УПРАВЛЕНИЕ:
|
||
|
||
Название файла надо вставить внутрь скрипта (ищите default.csv)
|
||
|
||
ПАРАМЕТРЫ:
|
||
|
||
N/A
|
||
|
||
|
||
ВЫВОД:
|
||
|
||
Файл monitor.png записывается в текущую директорию
|
||
|
||
|
||
ИСТОРИЯ:
|
||
 Роман Кривонос, ИКИ РАН, krivonos@cosmos.ru
|
||
Декабрь 2024
|
||
|
||
"""
|
||
|
||
import matplotlib.pyplot as plt
|
||
import numpy as np
|
||
from matplotlib import ticker
|
||
import pandas as pd
|
||
import datetime
|
||
import dateutil
|
||
|
||
|
||
|
||
fig, ax = plt.subplots(figsize=(9, 5), dpi=100)
|
||
|
||
|
||
#ax.set(xlabel='time (s)', ylabel='voltage (mV)',
|
||
# title='About as simple as it gets, folks')
|
||
|
||
ax.grid(visible=True,linestyle='dotted', )
|
||
|
||
#ax.grid()
|
||
plt.xlim([2020,2025])
|
||
plt.ylim([2,12])
|
||
ax.xaxis.set_minor_locator(ticker.MultipleLocator(1/12))
|
||
ax.yaxis.set_minor_locator(ticker.MultipleLocator(0.2))
|
||
ax.tick_params(axis="both", width=1, labelsize=14)
|
||
|
||
for axis in ['top','bottom','left','right']:
|
||
ax.spines[axis].set_linewidth(1)
|
||
|
||
cl='black'
|
||
|
||
# Сюда надо вставить название файла, скачанного с https://monitor.srg.cosmos.ru/
|
||
df = pd.read_csv('default.csv',)
|
||
|
||
|
||
tm=[]
|
||
rate=[]
|
||
|
||
for index, row in df.iterrows():
|
||
dt = dateutil.parser.parse(row['timestamp'])
|
||
day_of_year = dt.timetuple().tm_yday # returns 1 for January 1st
|
||
tm.append(dt.year+(day_of_year/365))
|
||
rate.append(float(row['value_60.0-120.0']))
|
||
|
||
plt.plot(tm, rate, color=cl, linewidth=1, linestyle='solid')
|
||
|
||
geminga_dt = datetime.date.fromisoformat('2023-04-16')
|
||
day_of_year = geminga_dt.timetuple().tm_yday # returns 1 for January 1st
|
||
geminga_tm=geminga_dt.year+(day_of_year/365)
|
||
plt.axvline(x = geminga_tm, color = 'b', linewidth=3 , linestyle='dashed', label = 'Geminga scan')
|
||
|
||
plt.ylabel('Count rate (counts s$^{-1}$)',fontsize=14, fontweight='normal')
|
||
plt.xlabel('Year',fontsize=14, fontweight='normal')
|
||
|
||
fig.savefig("monitor.png", bbox_inches='tight')
|
||
plt.show()
|