Created
October 2, 2020 20:56
-
-
Save alisterburt/88e4e6196905053ef6546f6e677836e3 to your computer and use it in GitHub Desktop.
fourier index to angstrom resolution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import click | |
@click.command() | |
@click.argument('fourier_pixel_extent', required=False) | |
@click.argument('angstroms_per_pixel', required=False) | |
@click.argument('box_size', required=False) | |
@click.option('-fpix', | |
'--fourier_pixel_extent', | |
help='Fourier pixel extent that you would like to convert into a resolution', | |
prompt='Fourier pixel extent: ', | |
type=float) | |
@click.option('-apix', | |
'--angstroms_per_pixel', | |
help='Pixel size in Angstroms', | |
prompt='Pixel size in Angstroms: ', | |
type=float,) | |
@click.option('-b', | |
'--box_size', | |
help='Box size in pixels', | |
prompt='Box size in pixels: ', | |
type=int) | |
def fpix2res(fourier_pixel_extent, angstroms_per_pixel, box_size): | |
""" | |
Convert extent of signal into fourier space into a resolution value in angstroms | |
""" | |
fraction_of_nyquist = float(fourier_pixel_extent) / (0.5 * box_size) | |
nyquist_frequency_angstroms = 1.0 / (2.0 * float(angstroms_per_pixel)) | |
spatial_frequency_angstroms = fraction_of_nyquist * nyquist_frequency_angstroms | |
resolution_angstroms = 1.0 / spatial_frequency_angstroms | |
click.echo(f'Resolution (Å): {resolution_angstroms}') | |
return resolution_angstroms | |
if __name__ == '__main__': | |
fpix2res() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment