Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
L
LOFAR-calculator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Astronomy and Operations
SDC Operations
LOFAR-calculator
Commits
88f1322d
Commit
88f1322d
authored
Jan 14, 2020
by
sarrvesh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add sun rise/set to plot in pdf
parent
6da7feaa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
4 deletions
+33
-4
generatepdf.py
generatepdf.py
+33
-4
No files found.
generatepdf.py
View file @
88f1322d
...
...
@@ -5,6 +5,9 @@ import os
from
fpdf
import
FPDF
,
HTMLMixin
import
matplotlib.dates
as
mdates
import
matplotlib.pyplot
as
plt
from
matplotlib.patches
import
Rectangle
from
pandas.plotting
import
register_matplotlib_converters
register_matplotlib_converters
()
# Dummy class needed to generate the PDF file
class
MyFPDF
(
FPDF
,
HTMLMixin
):
...
...
@@ -35,12 +38,38 @@ def make_pdf_plot(elevation_fig, outfilename):
hour_loc
=
(
0
,
3
,
6
,
9
,
12
,
15
,
18
,
21
)
ax
.
xaxis
.
set_major_locator
(
mdates
.
HourLocator
(
hour_loc
))
ax
.
xaxis
.
set_major_formatter
(
mdates
.
DateFormatter
(
'%H:%M'
))
plt
.
xlabel
(
'Time (UTC)'
)
plt
.
ylabel
(
'Elevation (deg)'
)
plt
.
title
(
'Target visibility plot'
)
plt
.
xlabel
(
'Time (UTC)'
,
fontsize
=
14
)
plt
.
ylabel
(
'Elevation (deg)'
,
fontsize
=
14
)
plt
.
title
(
'Target visibility plot'
,
fontsize
=
14
)
# Highlight sunrise
sun_rise_dict
=
elevation_fig
[
'layout'
][
'shapes'
][
0
]
temp_date
=
sun_rise_dict
[
'x0'
].
split
(
'.'
)[
0
]
x_min
=
datetime
.
strptime
(
temp_date
,
'%Y-%m-%dT%H:%M:%S'
)
temp_date
=
sun_rise_dict
[
'x1'
].
split
(
'.'
)[
0
]
x_max
=
datetime
.
strptime
(
temp_date
,
'%Y-%m-%dT%H:%M:%S'
)
y_min
=
sun_rise_dict
[
'y0'
]
y_max
=
sun_rise_dict
[
'y1'
]
rect
=
Rectangle
((
x_min
,
y_min
),
width
=
x_max
-
x_min
,
height
=
y_max
,
fill
=
True
,
edgecolor
=
None
,
facecolor
=
'lightskyblue'
)
ax
.
add_patch
(
rect
)
# Highlight sunset
sun_set_dict
=
elevation_fig
[
'layout'
][
'shapes'
][
1
]
temp_date
=
sun_set_dict
[
'x0'
].
split
(
'.'
)[
0
]
x_min
=
datetime
.
strptime
(
temp_date
,
'%Y-%m-%dT%H:%M:%S'
)
temp_date
=
sun_set_dict
[
'x1'
].
split
(
'.'
)[
0
]
x_max
=
datetime
.
strptime
(
temp_date
,
'%Y-%m-%dT%H:%M:%S'
)
y_min
=
sun_set_dict
[
'y0'
]
y_max
=
sun_set_dict
[
'y1'
]
rect
=
Rectangle
((
x_min
,
y_min
),
width
=
x_max
-
x_min
,
height
=
y_max
,
fill
=
True
,
edgecolor
=
None
,
facecolor
=
'lightskyblue'
)
ax
.
add_patch
(
rect
)
plt
.
ylim
([
0
,
90
])
if
len
(
elevation_fig
[
'data'
])
>
1
:
ax
.
legend
()
ax
.
legend
(
fontsize
=
14
)
plt
.
tight_layout
()
plt
.
savefig
(
outfilename
,
dpi
=
100
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment