Transport-for-the-North / caf.core

Core classes and definitions for CAF family of tools
GNU General Public License v3.0
0 stars 1 forks source link

Add segments seems to be duplicating rows when a one-to-many lookup is defined #53

Open suziebod opened 1 week ago

suziebod commented 1 week ago

Adding segment status_aps to an output 11 DVector seems to duplicate all rows instead of mapping using the lookup economic_status_to_status_aps.csv

from pathlib import Path

from caf.core.data_structures import DVector

# read in a DVector to IPF
input_path = Path(r'F:\Working\Land-Use\OUTPUTS_full run_final')
file = 'Output P11_EM.hdf'
# load dvector data
dvector = DVector.load(input_path / file)
# show dvector and number of rows
dvector.data
# try adding segments defined by the lookup economic_status_to_status_aps.csv and check number of rows
dvector.add_segments(new_segs=['status_aps']).data

Why does economic_status index value of 1 have mappings to status_aps values -8, 1, 2, 3, when the lookup says economic_status value = 1, status_aps value=1?

isaac-tfn commented 1 week ago

I think the issue is the lookup needs to be added to the segment definition too. Sorry I forgot before when I added the segment I'll add now and it should work.

isaac-tfn commented 1 week ago

Does seem to work now, let me know if it's ok on your end @suziebod and I'll close

suziebod commented 1 week ago

Yep same number of rows after adding the segmentation now - thanks @isaac-tfn