Skip to content

touchstone Export, feature request (code inside) #3

@oe2lsp

Description

@oe2lsp

Hi,
one last comment from my side, added touchstone export to postprocess.py/ function save_to_file
so that postprocessing in other engineering programs is easier

        net = skrf.Network(frequency=self.frequencies, s=self.s_params.transpose(2, 0, 1))
        file_path = 'export.sXp'
        touchstone_path = os.path.join(RESULTS_DIR,file_path) 
        logger.debug("Saving touchstone file %s ", touchstone_path)
        net.write_touchstone(filename=touchstone_path, write_z0=False, skrf_comment=True)
        
        with open(touchstone_path, 'r') as touchstone_file:
            touchstone_data = touchstone_file.read()
        #replace as some touchstone readers are picky
        touchstone_data = touchstone_data.replace(' 0 ', ' 0.0 ')
        touchstone_data = touchstone_data.replace('nan', '0.0')
        with open(touchstone_path, 'w') as touchstone_file:
            touchstone_file.write(touchstone_data)

if required I could file a pull request

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions