Skip to content

Instantly share code, notes, and snippets.

@alisterburt
Created October 2, 2020 20:55
Show Gist options
  • Save alisterburt/eae41286747f86a322b1e10206d36a89 to your computer and use it in GitHub Desktop.
Save alisterburt/eae41286747f86a322b1e10206d36a89 to your computer and use it in GitHub Desktop.
resolution in angstroms to fourier index
#!/usr/bin/env python
import click
@click.command()
@click.argument('resolution_angstroms', required=False)
@click.argument('angstroms_per_pixel', required=False)
@click.argument('box_size', required=False)
@click.option('-res',
'--resolution_angstroms',
help='Resolution in angstroms that you would like to convert into a fourier pixel extent',
prompt='Resolution in Angstroms: ',
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 res2fpix(resolution_angstroms, angstroms_per_pixel, box_size):
"""
Convert a resolution in angstroms into the distance from the origin in fourier space for a given pixel size and
box size
"""
spatial_frequency_angstroms = 1.0 / float(resolution_angstroms)
nyquist_frequency_angstroms = 1.0 / (2.0 * float(angstroms_per_pixel))
fraction_of_nyquist = spatial_frequency_angstroms / nyquist_frequency_angstroms
fourier_pixel_extent = fraction_of_nyquist * (0.5 * box_size)
click.echo(f'Fourier pixel extent (px): {fourier_pixel_extent}')
return fourier_pixel_extent
if __name__ == '__main__':
res2fpix()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment