Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update hextof tutorial notebook #421

Merged
merged 5 commits into from
Jul 8, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 34 additions & 61 deletions tutorial/4_hextof_workflow.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,16 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Download and unpack data"
"### Get data paths"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If it is your beamtime, you can access both read the raw data and write to processed directory. For the public data, you can not write to processed directory.\n",
"\n",
"The paths are such that if you are on Maxwell, it uses those. Otherwise data is downloaded in current directory from Zenodo."
]
},
{
Expand All @@ -56,10 +65,15 @@
"metadata": {},
"outputs": [],
"source": [
"# data_path can be defined and used to store the data in a specific location\n",
"dataset.get(\"Gd_W110\") # Put in Path to a storage of at least 10 Gbyte free space.\n",
"path = dataset.dir\n",
"print(path)"
"beamtime_dir = \"/asap3/flash/gpfs/pg2/2023/data/11019101\" # on Maxwell\n",
"if os.path.exists(beamtime_dir) and os.access(beamtime_dir, os.R_OK):\n",
" path = beamtime_dir + \"/raw/hdf/offline/fl1user3\"\n",
" buffer_path = beamtime_dir + \"/processed/tutorial/\"\n",
zain-sohail marked this conversation as resolved.
Show resolved Hide resolved
"else:\n",
" # data_path can be defined and used to store the data in a specific location\n",
" dataset.get(\"Gd_W110\") # Put in Path to a storage of at least 10 Gbyte free space.\n",
" path = dataset.dir\n",
" buffer_path = path + \"/processed/\""
]
},
{
Expand All @@ -84,6 +98,8 @@
},
"outputs": [],
"source": [
"# file to store the calibration parameters in\n",
"cal_file = \"hextof_tutorial_cal.yaml\" \n",
zain-sohail marked this conversation as resolved.
Show resolved Hide resolved
"# pick the default configuration file for hextof@FLASH\n",
"config_file = Path('../sed/config/flash_example_config.yaml')\n",
"assert config_file.exists()"
Expand All @@ -99,58 +115,13 @@
"config_override = {\n",
" \"core\": {\n",
" \"paths\": {\n",
" \"data_raw_dir\": \"\",\n",
" \"data_parquet_dir\": \"\"\n",
" \"data_raw_dir\": path,\n",
" \"data_parquet_dir\": buffer_path\n",
" },\n",
" },\n",
"}"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If it is your beamtime, you can access both read the raw data and write to processed directory. For the public data, you can not write to processed directory."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"config_override['core']['paths']['data_raw_dir'] = \"/asap3/flash/gpfs/pg2/2023/data/11019101/raw/hdf/offline/fl1user3\"\n",
"# If this will not work for you, please change it to a path where you have write access\n",
"config_override['core']['paths']['data_parquet_dir'] = \"/asap3/flash/gpfs/pg2/2023/data/11019101/processed\"\n",
"# So we write to user space\n",
"config_override['core']['paths']['data_parquet_dir'] = path + \"/processed\"\n",
"# If you aren't using maxwell and downloaded the data, use this path\n",
"config_override['core']['paths']['data_raw_dir'] = path"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### cleanup previous config files\n",
"In this notebook, we will show how calibration parameters can be generated. Therefore we want to clean the local directory of previously generated files.\n",
"\n",
"**WARNING** running the cell below will delete the \"sed_config.yaml\" file in the local directory. If these contain precious calibration parameters, **DO NOT RUN THIS CELL**."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"local_folder_config = Path('./sed_config.yaml')\n",
"if local_folder_config.exists():\n",
" os.remove(local_folder_config)\n",
" print(f'deleted local config file {local_folder_config}')\n",
"assert not local_folder_config.exists()"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -175,7 +146,7 @@
"metadata": {},
"outputs": [],
"source": [
"sp = SedProcessor(runs=[44762], config=config_override, system_config=config_file, collect_metadata=False, force_recreate=True)\n",
"sp = SedProcessor(runs=[44762], config=config_override, system_config=config_file, collect_metadata=False)\n",
zain-sohail marked this conversation as resolved.
Show resolved Hide resolved
"# You can set collect_metadata=True if the scicat_url and scicat_token are defined"
]
},
Expand Down Expand Up @@ -330,7 +301,7 @@
"metadata": {},
"outputs": [],
"source": [
"fig,ax = plt.subplots(1,3,figsize=(8,2), layout='tight')\n",
"fig,ax = plt.subplots(1,3,figsize=(10,3), layout='tight')\n",
"res_chessy.plot(ax=ax[0], robust=True)\n",
"res_t05.plot(ax=ax[1], robust=True)\n",
"res_t10.plot(ax=ax[2], robust=True)"
Expand Down Expand Up @@ -648,8 +619,8 @@
"metadata": {},
"outputs": [],
"source": [
"sp.save_energy_calibration()\n",
"sp.save_energy_offset()"
"sp.save_energy_calibration(cal_file)\n",
"sp.save_energy_offset(cal_file)"
]
},
{
Expand All @@ -665,7 +636,7 @@
"metadata": {},
"outputs": [],
"source": [
"sp.save_workflow_params()"
"sp.save_workflow_params(cal_file)"
]
},
{
Expand All @@ -692,6 +663,7 @@
"sp = SedProcessor(\n",
" runs=[44824,44825,44826,44827],\n",
" config=config_override,\n",
" user_config=cal_file,\n",
zain-sohail marked this conversation as resolved.
Show resolved Hide resolved
" system_config=config_file,\n",
" collect_metadata=False,\n",
")"
Expand Down Expand Up @@ -767,7 +739,7 @@
" constant=-1463.7, # this is time zero\n",
" flip_delay_axis=True, # invert the direction of the delay axis\n",
" columns=['bam'], # use the bam to offset the values\n",
" weights=[0.001], # bam is in fs, delay in ps\n",
" weights=[-0.001], # bam is in fs, delay in ps\n",
rettigl marked this conversation as resolved.
Show resolved Hide resolved
" preserve_mean=True # preserve the mean of the delay axis\n",
")"
]
Expand Down Expand Up @@ -860,7 +832,7 @@
},
"outputs": [],
"source": [
"sp.save_delay_offsets()"
"sp.save_delay_offsets(cal_file)"
]
},
{
Expand All @@ -884,6 +856,7 @@
"sp = SedProcessor(\n",
" runs=[44824,44825,44826,44827],\n",
" config=config_override,\n",
" user_config=cal_file,\n",
" system_config=config_file,\n",
" collect_metadata=False\n",
")"
Expand Down Expand Up @@ -982,9 +955,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.6"
"version": "3.8.12"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}