Skip to content

Feature request: wrap around NumPy masking #3

@chpxu

Description

@chpxu

Currently, pDOS data is stored in a dict mapping $(l,m)$-resolved DOS to the arrays of actual pDOS values, organised by spin. This is an easy-to-understand data structure, but it does mean that accessing array values is slightly cumbersome when you want to mask (i.e. restrict to a range of energies for plotting) values.

Current example with matplotlib:

lm = lmpdos.lm_dict
fig = plt.figure(figsize=(10, 5))
lenergy = -10
renergy = 0
energy_mask = np.ma.masked_inside(rel_fermi, lenergy, renergy).mask
x_energy = rel_fermi[energy_mask]
for key in ["2,-2","2,-1","2,0","2,1","2,2"]:
    plt.plot(x_energy, lm[key][0][energy_mask], label=key, color=color_dict[key])
    plt.plot(x_energy, -1 * lm[key][1][energy_mask], linestyle="--",color=color_dict[key])

In particular, lm[key][0][energy_mask] and having to reuse np.ma.masked* is repetitive.

Possible implementation:

  • Define a mask function inside pdos_processor
  • Define a new class attribute to hold the masked data, leaving the original untouched
  • Use this to form a getter/setter pair

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions