DiamondLightSource / Opt-ID

Code for the Optimisation of ID's using Python and Opt-AI
Apache License 2.0
7 stars 6 forks source link

Inconsistent .inp file format for APPLE_Symmetric insertion devices #55

Closed JossWhittle closed 4 years ago

JossWhittle commented 4 years ago

Specifically in field_generator.py the magnet direction field in the output file is the sum of the magnets direction matrix at indices ['direction_matrix'][0][0] and ['direction_matrix'][0][1]. https://github.com/DiamondLightSource/Opt-ID/blob/5eae8f15642c98cf762d889715f960801f36258e/IDSort/src/field_generator.py#L301-L345

line= ("%5i %4i %4i %4i %4i %4i\n"%(b+1,a+1,mag_type,info['beams'][b]['mags'][a]['direction_matrix'][0][0]+info['beams'][b]['mags'][a]['direction_matrix'][0][1],mag_flip, mag_num))

While in process_genome.py the value is ['direction_matrix'][1][1] if the magnet type is 1 or 3, otherwise it is ['direction_matrix'][2][2] if the magnet type is 2 or 4. https://github.com/DiamondLightSource/Opt-ID/blob/5eae8f15642c98cf762d889715f960801f36258e/IDSort/src/process_genome.py#L129-L178

if mag_type==3 or mag_type==1:
    line= ("%6i %5i %5i %5i %5i %05i\n"%(b+1,a+1,mag_type,info['beams'][b]['mags'][a]['direction_matrix'][1][1],mag_flip,mag_num))

elif mag_type==2 or mag_type==4:
    line= ("%6i %5i %5i %5i %5i %05i\n"%(b+1,a+1,mag_type,info['beams'][b]['mags'][a]['direction_matrix'][2][2],mag_flip,mag_num))

field_generator.py always creates a hard coded file for DLS beamline I21 named I21_setmag.inp so it is possible the code there is only for testing and can be removed safely.

@markbasham Is the I21_setmag.inp file creation in field_generator.py important / needed ?

JossWhittle commented 4 years ago

The __main__ code path in field_generator.py is not used in the current user directions for the software and is a good candidate to be removed entirely as this functionality is now present in other scripts and was originally hard coded for use on DLS beamline I21.

JossWhittle commented 4 years ago

Closed by #57