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

added function to truncate by index and spectral window #8

Closed
wants to merge 4 commits into from

Conversation

abit2
Copy link
Member

@abit2 abit2 commented Mar 12, 2017

It is the initial commit for IRISRaster object method with which object can now be truncated by index of time, raster_position, slit_axis and spectral window at the moment.
let me know if there is any need for more by index method.
Made changes to the repr as it was not able to show the changes in the data so made it somewhat dynamic for now, not sure if it will work for every change may need more work.
More work will be done on it in this branch:).
@DanRyanIrish

@DanRyanIrish
Copy link
Member

Hi @abit2. What's the reasoning for changing the __repr__ function of IRISRaster?

@DanRyanIrish
Copy link
Member

Hi @abit2. I've been giving this some more thought. I think what we want is a truncate function, similar to what TimeSeries has. Perhaps we also want something like the sel function in xarray.dataset. But I think trying to get all the functionality we want in one API is asked too much. I'll write up an issue describing what we need so you can start another PR for the truncate function. Once that's done we can come back to a simpler version of this sel function than I initially described.

@DanRyanIrish
Copy link
Member

But before, moving on from this PR, I think you should restore __repr__ to how it was as it's not part of this functionality change. Unless you have a good reason that it should be changed?

@DanRyanIrish
Copy link
Member

Here is the link to the issue. Let me know if you have questions and we can discuss it next week.
#12

return "<iris.IRISRaster instance\nOBS ID: {0}\n".format(self.meta["observation ID"]) + \
"OBS Description: {0}\n".format(self.meta["observation description"]) + \
"OBS period: {0} -- {1}\n".format(self.meta["observation start"], self.meta["observation end"]) + \
"Instance period: {0} -- {1}\n".format(self.data[spectral_window].time.values[0],
Copy link
Member Author

Choose a reason for hiding this comment

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

if there is only one element in .data[spectral_window].time.values then using 0 th index gives an error

Copy link
Member

Choose a reason for hiding this comment

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

I think as above, the result will be an array of length 1. So giving the using the 0th index will work. If this is not the case, it should be. We don't want the type of an attribute to change just because the length changes. But again, it would good if you could confirm this.

Copy link
Member Author

Choose a reason for hiding this comment

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

error

@@ -229,17 +229,29 @@ def __init__(self, filenames, spectral_windows="All"):

def __repr__(self):
spectral_window = self.spectral_windows["name"][0]
spectral_windows_info = "".join(
["\n {0}\n (raster axis: {1}, slit axis: {2}, spectral axis: {3})".format(
name, len(self.data[name].raster_axis), len(self.data[name].slit_axis),
Copy link
Member Author

Choose a reason for hiding this comment

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

suppose someone studies only one raster_axis so he/she truncates by index then length of an integer gives an error.

Copy link
Member

Choose a reason for hiding this comment

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

I believe that if there is only one element along the raster_axis, then self.data[name].raster_axis will be an array of length 1, not an integer. If this is the case, then it should still work as written.

Copy link
Member Author

Choose a reason for hiding this comment

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

error1

@abit2
Copy link
Member Author

abit2 commented Mar 17, 2017

@DanRyanIrish can you please look into the PR when you have time.
Added truncating by __and and __or method, slice and indexing.
:)
Sorry for the late PR.
btw travis build is failing in the docs will be fixed.

@@ -229,17 +229,29 @@ def __init__(self, filenames, spectral_windows="All"):

def __repr__(self):
spectral_window = self.spectral_windows["name"][0]
spectral_windows_info = "".join(
["\n {0}\n (raster axis: {1}, slit axis: {2}, spectral axis: {3})".format(
name, len(self.data[name].raster_axis), len(self.data[name].slit_axis),
Copy link
Member

Choose a reason for hiding this comment

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

I believe that if there is only one element along the raster_axis, then self.data[name].raster_axis will be an array of length 1, not an integer. If this is the case, then it should still work as written.

@@ -15,9 +15,9 @@
from astropy import constants
from scipy import interpolate
from sunpy.time import parse_time

from sunpy.net.vso import 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.

I think we should have more descriptive variable names than a. But attrs is also too generic. Perhaps it would be better to do from sunpy.net import vso.attrs.

return "<iris.IRISRaster instance\nOBS ID: {0}\n".format(self.meta["observation ID"]) + \
"OBS Description: {0}\n".format(self.meta["observation description"]) + \
"OBS period: {0} -- {1}\n".format(self.meta["observation start"], self.meta["observation end"]) + \
"Instance period: {0} -- {1}\n".format(self.data[spectral_window].time.values[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 think as above, the result will be an array of length 1. So giving the using the 0th index will work. If this is not the case, it should be. We don't want the type of an attribute to change just because the length changes. But again, it would good if you could confirm this.

@DanRyanIrish
Copy link
Member

I'll take a closer look at the new parts of your code during the week. Thanks again for the contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants