Action #3535

Allow building of a file function from scratch

Added by Knödlseder Jürgen about 3 years ago. Updated about 3 years ago.

Status:ClosedStart date:02/04/2021
Priority:HighDue date:
Assigned To:Knödlseder Jürgen% Done:

100%

Category:-
Target version:2.0.0
Duration:

Description

So far it is not possible to build a GModelSpectralFunc from scratch in memory, the class can only read information from an ASCII file. Methods should be added to allow building from scratch, similar to the methods that are available for the GModelSpectralNodes class.


Recurrence

No recurrence.

History

#1 Updated by Knödlseder Jürgen about 3 years ago

  • Status changed from New to In Progress

I added the following methods to GModelSpectralFunc to allow manipulating of file function nodes. Note that the methods assure that nodes are always in increase order of energy. Appending, inserting or setting a node that would violate that order will lead to exceptions. Also nodes with non-positive intensities will lead to an exception.

int     nodes(void) const;
bool    is_empty(void) const;
void    append(const GEnergy& energy, const double& intensity);
void    insert(const GEnergy& energy, const double& intensity);
void    remove(const int& index);
void    reserve(const int& num);
void    extend(const GModelSpectralFunc& filefct);
GEnergy energy(const int& index) const;
void    energy(const int& index, const GEnergy& energy);
double  intensity(const int& index) const;
void    intensity(const int& index, const double& intensity);
void    save(const GFilename& filename, const bool& clobber = false) const;

#2 Updated by Knödlseder Jürgen about 3 years ago

  • Status changed from In Progress to Pull request
  • % Done changed from 0 to 90

I added unit tests to check all new methods.

#3 Updated by Knödlseder Jürgen about 3 years ago

  • % Done changed from 90 to 100

Code was merged into devel.

#4 Updated by Knödlseder Jürgen about 3 years ago

  • Status changed from Pull request to Closed

Also available in: Atom PDF