-
-
Notifications
You must be signed in to change notification settings - Fork 573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Magnetogram overplotting gallery example #2037
Conversation
Hello @Punyaslok! Thanks for updating the PR.
Comment last updated on August 04, 2017 at 09:13 Hours UTC |
The build has failed due to a bug which is fixed in master. I suggest you rebase on master than then rebase again when we merge the SRS code. |
daa936a
to
53f6443
Compare
############################################################################## | ||
# Start by importing the necessary modules. | ||
|
||
from sunpy.net import Fido, attrs as a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the sunpy import should be in the second block:
stdlib
external
sunpy
# Download the files. | ||
|
||
downresp = Fido.fetch(results) | ||
#downresp = ['/home/punya/sunpy/data/hmi_m_45s_2017_01_01_00_02_15_tai_magnetogram.fits'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
############################################################################## | ||
# Download the files. | ||
|
||
downresp = Fido.fetch(results) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
downresp is not a great variable name downloaded_files
is probably better.
# Download the SRS file. | ||
|
||
srs_results = Fido.search(a.Time(start_time, end_time), a.Instrument('SOON')) | ||
#srs_downresp = ['/home/punya/sunpy/data/20170101SRS.txt'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
############################################################################## | ||
# Now we make the plot. | ||
|
||
############################################################################## |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
each of these blocks should have code in it so this should only be one row of comments
|
||
smap = sunpy.map.Map(file_name) | ||
|
||
im = smap.plot() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you use im
again? if not remove it.
also the gallery examples should be very strict with PEP 8, so make the tireless bot happy ;) (for that file) |
# We will select a small time range to avoid downloading too many files. | ||
|
||
start_time = day + " 00:01:00" | ||
end_time = day + " 00:02:00" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not too happy to add strings starting with spaces. In this case I may suggest to put the date and time together as strings, eg:
start_time = "2017-01-01 00:01:00"
end_time = "2017-01-01 00:02:00"
or to do it using datetime
like
start_time = datetime.datetim(2017, 1, 1, 0, 1, 0)
end_time = start_time + datetime.timedelta(0, 60)
For this example I probably would go with the first option, but I don't see the point to have strings with dates when python treats dates properly (it's just reminds me too much to idl)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The strings could start with T instead.
# now `srs_table` contains an astropy table. | ||
|
||
srs_table = srs.read_srs(srs_downresp[0]) | ||
print (srs_table) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not spaces after print
please ;)
# Add the numbers as labels for each point. | ||
|
||
for i, num in enumerate(numbers): | ||
ax.annotate(num, (lngs[i].value, lats[i].value), xycoords=ax.get_transform('heliographic_stonyhurst')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
num should be formatted in 10000
after 2002-06-15.
dbf720f
to
2145122
Compare
0fd05c0
to
32a41fb
Compare
Note : Now this also requires #2170 to be merged LOL 😇 |
it's rebase o'clock |
… add magnetogram_active_regions.py !
9aa48a9
to
412adf9
Compare
# Now to download and read the SRS file. | ||
# Download the SRS file. | ||
|
||
srs_results = Fido.search(a.Time(start_time, end_time), a.Instrument('SOON')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we change the instrument here to SRS_table
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
# We only need the rows which have 'ID' = 'I' or 'IA'. | ||
|
||
if 'I' in srs_table['ID'] or 'IA' in srs_table['ID']: | ||
srs_table = srs_table[np.logical_or( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not line break this here in a gallery example. If you really want to line break I would do it after a ,
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But concerned about too many a[0]
when we suppose to get only one file
############################################################################## | ||
# As the `fetch` method returns a list, our filename is its first element. | ||
|
||
file_name = downloaded_files[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get all the indexing if in result
we have chosen only the first file, why then we call the next one downloaded_files
and then index that one again to get its filename.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
corrected
|
||
############################################################################## | ||
# Now to download and read the SRS file. | ||
# Download the SRS file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two sentences are redundant...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
corrected
srs_downloaded_files = Fido.fetch(srs_results) | ||
|
||
############################################################################## | ||
# We get one SRS file per day. So we pass the filename into the SRS reader. So |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we get one file per day... but we queried only for one day... does this mean we are getting more than one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, we get one file per day, but [0] is necessary here because read_srs expects str, bytes or os.PathLike object, not list.
Note : This requires #1852 to be merged.
To-do :
@Cadair @dpshelio