Skip to content

Commit

Permalink
Merge pull request #15 from ngergihun/master
Browse files Browse the repository at this point in the history
New reader and transform classes
  • Loading branch information
ngergihun authored Sep 19, 2024
2 parents 660ff63 + bf03937 commit 06b0450
Show file tree
Hide file tree
Showing 9 changed files with 403 additions and 279 deletions.
4 changes: 2 additions & 2 deletions pySNOM/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Scanning Near-field Optical Microscopy (SNOM) analysis tools
"""
from .defaults import defaults
from .images import Image, Process
from .images import Image, Transformation
from .readers import Reader
from .spectra import NeaSpectrum, NeaInterferogram
# import images
Expand All @@ -14,4 +14,4 @@
__version__ = '0.0.2'
__author__ = 'Gergely Németh, Ferenc Borondics'
__credits__ = 'Wigner Research Centre for Physics, Synchrotron SOLEIL'
__all__ = ["defaults","Reader","Image","Process","NeaSpectrum","NeaInterferogram"]
__all__ = ["defaults","Reader","Image","Transformation","NeaSpectrum","NeaInterferogram"]
61 changes: 22 additions & 39 deletions pySNOM/examples/imageprocess.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 8,
"metadata": {},
"outputs": [
{
Expand All @@ -24,59 +24,42 @@
],
"source": [
"import numpy as np\n",
"from pySNOM.readers import Reader\n",
"from pySNOM.images import Image, Data, DataTypes\n",
"import pySNOM\n",
"from pySNOM import readers\n",
"import os\n",
"\n",
"filename = r'C:\\Users\\NEMETHG\\OneDrive\\Python\\pySNOM\\pySNOM\\datasets\\testPsHetData.gwy'\n",
"f = 'datasets/testPsHetData.gwy'\n",
"file_reader = readers.GwyReader(fullfilepath=os.path.join(pySNOM.__path__[0], f),channelname='O3A raw')\n",
"gwy_image = file_reader.read()\n",
"\n",
"file_reader = Reader(filename)\n",
"# From raw data black\n",
"# Reads all the files\n",
"rawgwydata = file_reader.read_gwyfile()\n",
"measurement = Data(filename = filename, data = rawgwydata, mode = 'PsHet')\n",
"O3Aimage = measurement.getImageFromChannel('O3A raw')\n",
"\n",
"# From a single channel\n",
"channel_name = 'O3A raw'\n",
"O3Achanneldata = file_reader.read_gwychannel(channel_name)\n",
"O3Aimage = Image(O3Achanneldata)\n",
"O3Aimage.setChannel(channel_name)\n",
"print(f'Pixel 7-7: {O3Aimage.data[7][7]}')\n",
"print(f'Pixel 8-8: {O3Aimage.data[8][8]}')\n",
"print(f'Pixel 8-9: {O3Aimage.data[9][9]}')\n",
"\n",
"# Read the info file\n",
"info_filename = r'C:\\Users\\NEMETHG\\OneDrive\\Python\\pySNOM\\pySNOM\\datasets\\testinfofile.txt'\n",
"file_reader.setFilename(info_filename)\n",
"infodict = file_reader.read_nea_infofile()\n",
"# Set parameters from the info dictionary\n",
"O3Aimage.setParameters(infodict=infodict)"
"print(f'Pixel 7-7: {gwy_image.data[7][7]}')\n",
"print(f'Pixel 8-8: {gwy_image.data[8][8]}')\n",
"print(f'Pixel 8-9: {gwy_image.data[9][9]}')"
]
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" Measurement mode: MeasurementModes.PsHet\n",
" Channel: O2A raw\n",
" Data type: DataTypes.Amplitude\n",
" Demod order: 2\n",
"X resolution: 200\n",
"Data size: (200, 200)\n",
"PLT-EV-niceplace_spectrum_1665_cm-1\n"
"Pixel 7-7: 15.213262557983398\n",
"Pixel 8-8: 15.736936569213867\n",
"Pixel 8-9: 13.609171867370605\n"
]
}
],
"source": [
"print(f' Measurement mode: {O3Aimage.mode}\\n Channel: {O3Aimage.channel}\\n Data type: {O3Aimage.datatype}\\n Demod order: {O3Aimage.order}')\n",
"print(f'X resolution: {O3Aimage.xres}')\n",
"print(f'Data size: {np.shape(O3Aimage.data)}')\n",
"print(O3Aimage.parameters['Description'])"
"f = 'datasets/testPsHet O3A raw.gsf'\n",
"file_reader = readers.GsfReader(os.path.join(pySNOM.__path__[0], f))\n",
"gwy_image = file_reader.read()\n",
"\n",
"print(f'Pixel 7-7: {gwy_image.data[7][7]}')\n",
"print(f'Pixel 8-8: {gwy_image.data[8][8]}')\n",
"print(f'Pixel 8-9: {gwy_image.data[9][9]}')"
]
},
{
Expand Down Expand Up @@ -190,7 +173,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.0"
"version": "3.11.6"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 06b0450

Please sign in to comment.