spacepy.datamodel.ISTPArray¶
- class spacepy.datamodel.ISTPArray[source]¶
Mixin class for array using ISTP metadata.
Array types like
dmarrayprovide all these methods; they assume attributes of the array use the ISTP metadata standard and are unlikely to give good results if that is not the case.Note that some operations that may seem to relate to an array (e.g. uncertainties) may require the use of other arrays in a container; these are in
ISTPContainer.Added in version 0.5.0.
- __init__(*args, **kwargs)¶
Methods
fromQuantity(q[, copy])Convert from Astropy Quantity
Determines if this array is better plotted as a lineplot or spectrogram.
Return data from array with invalid values replaced by
nan.toQuantity([copy])Convert to Astropy Quantity
units([fmt])Finds units of array.
Attributes
- classmethod fromQuantity(q, copy=True)[source]¶
Convert from Astropy Quantity
Converts an Astropy
Quantityto an ISTP array.nanare replaced with fill.- Parameters:
- q
Quantity Quantity to convert
- q
- Returns:
ISTPArrayArray with attributes which can be inferred from input. This may not be fully ISTP-compliant.
- Other Parameters:
- copy
bool, defaultTrue Copy data from the Quantity. If
False, changes to the Quantity may affect this array. In some cases a copy may be made even ifFalse.
- copy
Notes
Added in version 0.6.0.
- plot_as_line()[source]¶
Determines if this array is better plotted as a lineplot or spectrogram.
Uses array shape and the
DISPLAY_TYPEattribute to determine if should be plotted as a lineplot (potentially stacked) or spectrogram.- Returns:
boolTrueif should be a lineplot,Falseif should be a spectrogram
Notes
Added in version 0.5.0.
- replace_invalid()[source]¶
Return data from array with invalid values replaced by
nan.Makes a copy of the data and, for any values equal to the
FILLLVALattribute, greater thanVALIDMAX, or less thanVALIDMIN, replace with NaN.- Returns:
ndarrayTransformed data
See also
pycdf.istp.nanfillan in-place variant
Notes
Added in version 0.5.0.
Comparisons with
FILLVALare done usingiscloseand so may replace values that are near, but not identical, to fill.
- toQuantity(copy=True)[source]¶
Convert to Astropy Quantity
Converts this array to an Astropy
Quantity. Invalid values are replaced withnan.- Returns:
QuantityData from this array interpreted according to its
UNITSattribute.
- Other Parameters:
- copy
bool, defaultTrue Copy data to the Quantity. If
False, changes to the Quantity may affect the source array. In some cases a copy may be made even ifFalse.
- copy
Notes
Added in version 0.6.0.
Examples
>>> import spacepy.datamodel # https://rbsp-ect.newmexicoconsortium.org/data_pub/rbspa/ECT/level2/ >>> data = spacepy.datamodel.fromCDF( ... 'rbspa_ect-elec-L2_20140115_v2.1.0.cdf') >>> q = data['Position'].toQuantity() >>> q.to('m') <Quantity [[-32833200. , -15531762. , -6449212. ], [-32903586. , -15406271. , -6448704.5], [-32967848. , -15277711. , -6446542.5], ..., [-20966128. , 6941849.5, -2896334.2], [-21515586. , 6858618. , -3026324. ], [-22047328. , 6783260.5, -3153003.5]] m>
- units(fmt='minimal')[source]¶
Finds units of array.
Looks up the unit attribute and performs minor cleanup (including intepreting IDL codes).
- Parameters:
- fmt{‘minimal’, ‘latex’, ‘astropy’, ‘raw’}
How to format the units:
minimal(default) is a minimally-processed rendering,latexis in LaTeX,astropyis meant to give good results when passed toastropy.units.Unit, andrawhas no processing. No checks are done on processing for AstroPy or LaTeX, and it should not be assumed they will parse.
- Returns:
Notes
Added in version 0.6.0.
