Opened 13 years ago

Closed 12 years ago

#123 closed defect (fixed)

Improve voxel list handling

Reported by: MatthewWhiting Owned by: MatthewWhiting
Priority: normal Milestone: Release-1.2
Component: Code base Version: 1.1.13
Severity: normal Keywords:
Cc:

Description

There are a number of functions that take a vector of Voxels with which to calculate the various parameters of a Detection.

This is quite inefficient, which becomes obvious for large detections (ie. million+ voxels).

A better approach would be to use std::map, where the voxel set is directly accessed via the voxel location.

Change History (5)

comment:1 Changed 13 years ago by MatthewWhiting

Status: newassigned

This is how you would fix Detection::calcFluxes(std::vector<Voxel> voxelList):

  • Provide the list of voxels via std::map<Voxel,float>, where the float is the flux value of the voxel. The Voxel element itself should have zero flux.
  • Loop over the Detection's pixelset, rather than the input list
  • First do a check via std::map::find that the voxel under consideration is present. If not, report an error and exit.
  • This means we can get rid of the voxelListCovered() function

Code inside the loop would be something like:

if(voxellist.find(*vox)==voxellist.end()) ERROR + EXIT;
long x = ... [as before]
float f = voxellist[*vox];

then everything else as it is.

comment:2 Changed 13 years ago by MatthewWhiting

The same comments apply to the Detection::calcIntegFlux(long zdim, std::vector<Voxel> voxelList, FitsHeader? &head) and Detection::calcVelWidths(long zdim, std::vector<Voxel> voxelList, FitsHeader? &head) functions, where the loop code would be structured in the same way.

comment:3 Changed 13 years ago by MatthewWhiting

Have added a comparison function (operator<) for Voxel in [858]. This will allow Voxels to be used in std::map structures. The comparison is done first by position (looking at z, then y, then x) and then, if those are all equal, by flux.

comment:4 Changed 12 years ago by MatthewWhiting

Milestone: Release-1.1.14

Where are we up to with this? Look at the status of things for 1.1.14 - if sufficient, can we close this ticket?

comment:5 Changed 12 years ago by MatthewWhiting

Resolution: fixed
Status: assignedclosed

I think this is sufficient for the moment - the functionality that is here has been tested in Selavy, and I don't think anything new is required for now.

Closing.

Note: See TracTickets for help on using tickets.