html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue https://github.com/pydata/xarray/issues/706#issuecomment-192114256,https://api.github.com/repos/pydata/xarray/issues/706,192114256,MDEyOklzc3VlQ29tbWVudDE5MjExNDI1Ng==,1217238,2016-03-04T05:39:43Z,2016-03-04T05:39:43Z,MEMBER,"> This would already be quite cool! But would the mechanism allow to pass arguments to the MyLibGis class at construction time? This might also be wordy, maybe something like `ds = xray.DataArray(data, gis={'arg1':42})`? My suggested approach here would be to simply write functions instead, e.g., ``` def make_gis_array(data, gis=None): data = xr.DataArray(data) data.attrs['gis'] = gis # or whatever ``` This is similar to how I would suggest inserting lazy variables, i.e., write your own functions using `dask.array`: ``` def add_lazy_vars(data): if 'P' in data and 'PB' in data: data['TP'] = data['P'].chunk() + data['PB'].chunk() return data ``` ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,124915222 https://github.com/pydata/xarray/issues/706#issuecomment-169099306,https://api.github.com/repos/pydata/xarray/issues/706,169099306,MDEyOklzc3VlQ29tbWVudDE2OTA5OTMwNg==,1217238,2016-01-05T19:05:57Z,2016-01-05T19:06:06Z,MEMBER,"Back when I was doing spectroscopy in grad school, I wrote some routines to keep track of the units in Fourier transforms. I put this up on GitHub last year: https://github.com/shoyer/fourier-transform. I'm sure I'm not the only person to have written this code, but it still might be a useful point of departure. As for xray, I agree that the full extent of what you're describing is probably out of scope for xarray itself. However, a basic labeled FFT does seem like it would be a useful addition to the core library. Nevertheless, I am very interested in supporting external packages like this, either via subclassing or a similar mechanism. One possibility would be a mechanism for registering ""namespace"" packages that define additional methods (as I have [mentioned previously](https://github.com/pydata/xarray/issues/605#issuecomment-145299557)). You could write something like: ``` python # this code exists in your library ""specarray"" class SpecArray(object): def __init__(self, xray_obj): self.obj = xray_obj def fft(self): ... return freq, transformed_obj xray.register_accessor('spec', SpecArray) # this is what user code looks like import specarray import xray ds = xray.DataArray(...) ds.spec.fft() # calls the SpecArray.fft method ``` This might be easier than maintaining a full subclass, which tends to require a lot of work and presents backwards compatibility issues when we update internal methods. ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,124915222