.

# 2.0 - 2.1 Migration: nparray¶

Although not well-documented, PHOEBE 2.0 included the ability to directly set linspace or arange to an array while only storing the properties (start, stop, step, etc). If for some reason you managed to find and use the capability, the behavior has changed slightly and is included in a separate package called nparray, which is included and built within PHOEBE 2.1 as phoebe.dependencies.nparray.

Besides having much more flexibility, the only user-interface changes are that you cannot directly set the attributes for the properties from the Parameter.

In PHOEBE 2.0.x:

b.get_parameter('times').stop = 1

In PHOEBE 2.1.x:

b.get_parameter('times').set_property(stop=1)

## Introduction to nparray¶

If you didn’t happen to stumble on this in PHOEBE 2.0, you may find it useful. The nparray functionality allows you to store the start, stop, step values (in the case of linspace) instead of the entire array in memory. This is significantly cheaper to store when saving to json, for example, and allows for easily editing your step size without having to change the entire array. If you are writing your PHOEBE code within a script, this may seem like no use to you, but if you are in an interactive python console, then this can be quite handy.

The most useful of these “array creation functions” are also copied into the top-level of the phoebe package. These include: linspace, arange, logspace, and geomspace.

import phoebe
phoebe.linspace(0, 1, 11)

<linspace start=0 stop=1 num=11 endpoint=True unit=None>


By setting a PHOEBE parameter to this value, you can then later edit any of the properties.

b = phoebe.default_binary()

<ParameterSet: 15 parameters | contexts: compute, dataset>

print b.get_parameter('times')

Parameter: times@lc01@dataset
Qualifier: times
Description: Observed times
Value: <linspace start=0 stop=1 num=11 endpoint=True unit=d>
Constrained by:
Constrains: None
Related to: None


You can see here that the value is being stored not as an array, but as an nparray object with the properties to create that array. Once you (or PHOEBE) call get_value (or get_quantity), the array is temporarily created on-the-fly and returned.

print b.get_value('times')

[ 0.   0.1  0.2  0.3  0.4  0.5  0.6  0.7  0.8  0.9  1. ]


You can now “edit” the properties of this array without re-building it.

b.get_parameter('times').set_property(stop=2)

print b.get_parameter('times')

Parameter: times@lc01@dataset
Qualifier: times
Description: Observed times
Value: <linspace start=0 stop=2 num=11 endpoint=True unit=d>
Constrained by:
Constrains: None
Related to: None

print b.get_value('times')

[ 0.   0.2  0.4  0.6  0.8  1.   1.2  1.4  1.6  1.8  2. ]