mirror of
https://github.com/cdtools-developers/cdtools.git
synced 2026-11-10 16:24:00 +01:00
Start cleaning up the repo and tidying up the example scripts
This commit is contained in:
1 parent
76e6d5efae
commit
8ddcc7683f
18 files changed
+127
-574
No files matched your search
@@ -1,4 +1,3 @@
|
||||
from __future__ import division, print_function, absolute_import
|
||||
import numpy as np
|
||||
import torch as t
|
||||
from matplotlib import pyplot as plt
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,34 +1,33 @@
|
||||
from __future__ import division, print_function, absolute_import
|
||||
|
||||
import CDTools
|
||||
from matplotlib import pyplot as plt
|
||||
import pickle
|
||||
import time
|
||||
from scipy import io
|
||||
|
||||
# First, we load an example dataset from a .cxi file
|
||||
filename = 'example_data/AuBalls_700ms_30nmStep_3_6SS_filter.cxi'
|
||||
dataset = CDTools.datasets.Ptycho2DDataset.from_cxi(filename)
|
||||
|
||||
# Next, we create a ptychography model from the dataset
|
||||
# Note that we explicitly as for two incoherent probe modes
|
||||
model = CDTools.models.FancyPtycho.from_dataset(dataset, n_modes=2,dm_rank=0, probe_support_radius=50)
|
||||
# Note that we explicitly ask for two incoherent probe modes
|
||||
model = CDTools.models.FancyPtycho.from_dataset(dataset, n_modes=2)
|
||||
|
||||
# Let's do this reconstruction on the GPU, shall we?
|
||||
model.to(device='cuda')
|
||||
dataset.get_as(device='cuda')
|
||||
|
||||
# Now, we run a short reconstruction from the dataset
|
||||
for loss in model.Adam_optimize(100, dataset, batch_size=50, schedule=True):
|
||||
# And we liveplot the updates to the model as they happen
|
||||
print(model.report())
|
||||
model.inspect(dataset)
|
||||
|
||||
# And we save the reconstruction out to a file
|
||||
#with open('example_reconstructions/gold_balls.pickle', 'wb') as f:
|
||||
# pickle.dump(model.save_results(dataset),f)
|
||||
|
||||
# This orthogonalizes the incoherent probe modes
|
||||
model.tidy_probes()
|
||||
|
||||
# And we save out the results as a .mat file
|
||||
io.savemat('example_reconstructions/gold_balls.mat',
|
||||
model.save_results(dataset))
|
||||
|
||||
# Finally, we plot the results
|
||||
model.inspect(dataset)
|
||||
#model.compare(dataset)
|
||||
model.compare(dataset)
|
||||
plt.show()
|
||||
@@ -1,8 +1,6 @@
|
||||
from __future__ import division, print_function, absolute_import
|
||||
|
||||
import CDTools
|
||||
from matplotlib import pyplot as plt
|
||||
import time
|
||||
|
||||
# First, we load an example dataset from a .cxi file
|
||||
filename = 'example_data/lab_ptycho_data.cxi'
|
||||
dataset = CDTools.datasets.Ptycho2DDataset.from_cxi(filename)
|
||||
@@ -10,11 +8,10 @@ dataset = CDTools.datasets.Ptycho2DDataset.from_cxi(filename)
|
||||
# Next, we create a ptychography model from the dataset
|
||||
model = CDTools.models.SimplePtycho.from_dataset(dataset)
|
||||
|
||||
t = time.time()
|
||||
# Now, we run a short reconstruction from the dataset!
|
||||
for i, loss in enumerate(model.Adam_optimize(40, dataset,lr=0.01,batch_size=25)):#,batch_size=10000)):#0.001)):
|
||||
print(i, loss)
|
||||
print(time.time() - t)
|
||||
for loss in model.Adam_optimize(20, dataset):
|
||||
print(model.report())
|
||||
|
||||
# Finally, we plot the results
|
||||
model.inspect(dataset)
|
||||
model.compare(dataset)
|
||||
|
||||
Reference in new issue
Block a user