Skip to content
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

Merged
merged 12 commits into from
Aug 4, 2017

Conversation

Punyaslok
Copy link
Member

@Punyaslok Punyaslok commented Mar 13, 2017

Note : This requires #1852 to be merged.

To-do :

@Cadair @dpshelio

@pep8speaks
Copy link

pep8speaks commented Mar 13, 2017

Hello @Punyaslok! Thanks for updating the PR.

Line 63:76: W291 trailing whitespace

Line 61:21: E128 continuation line under-indented for visual indent
Line 402:1: E101 indentation contains mixed spaces and tabs
Line 402:1: W191 indentation contains tabs
Line 403:1: E101 indentation contains mixed spaces and tabs

Line 294:101: E501 line too long (108 > 100 characters)
Line 454:79: W291 trailing whitespace
Line 471:79: W291 trailing whitespace
Line 474:9: E731 do not assign a lambda expression, use a def

Comment last updated on August 04, 2017 at 09:13 Hours UTC

@Cadair
Copy link
Member

Cadair commented Mar 27, 2017

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.

##############################################################################
# Start by importing the necessary modules.

from sunpy.net import Fido, attrs as a
Copy link
Member

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']
Copy link
Member

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)
Copy link
Member

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']
Copy link
Member

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.

##############################################################################
Copy link
Member

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()
Copy link
Member

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.

@Cadair
Copy link
Member

Cadair commented Mar 27, 2017

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"
Copy link
Member

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)

Copy link
Member

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)
Copy link
Member

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'))
Copy link
Member

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.

@nabobalis nabobalis added the Examples Affects the Example Gallery label Apr 12, 2017
@Punyaslok Punyaslok force-pushed the magnetogram_gallery_example branch 2 times, most recently from dbf720f to 2145122 Compare June 24, 2017 07:45
@Punyaslok Punyaslok force-pushed the magnetogram_gallery_example branch from 0fd05c0 to 32a41fb Compare July 12, 2017 21:00
@Cadair Cadair added this to Nice to Haves in SunPy 0.8 Jul 17, 2017
@Punyaslok
Copy link
Member Author

Note : Now this also requires #2170 to be merged LOL

😇

@Cadair
Copy link
Member

Cadair commented Jul 26, 2017

it's rebase o'clock git rebase all the things.

@Cadair Cadair force-pushed the magnetogram_gallery_example branch from 9aa48a9 to 412adf9 Compare August 3, 2017 08:01
# 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'))
Copy link
Member

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?

Copy link
Member Author

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(
Copy link
Member

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 ,.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@Cadair Cadair added the Needs Review Needs reviews before merge label Aug 3, 2017
Copy link
Member

@dpshelio dpshelio left a 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]
Copy link
Member

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.

Copy link
Member Author

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.
Copy link
Member

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...

Copy link
Member Author

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
Copy link
Member

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?

Copy link
Member Author

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.

@Cadair Cadair merged commit 5837de4 into sunpy:master Aug 4, 2017
@Cadair Cadair moved this from Nice to Haves to Finished in SunPy 0.8 Aug 4, 2017
@nabobalis nabobalis removed the Needs Review Needs reviews before merge label Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Examples Affects the Example Gallery
Projects
No open projects
SunPy 0.8
Finished
Development

Successfully merging this pull request may close these issues.

None yet

5 participants