Browse Source

debug

joschka_dev
Jianshun Gao 1 year ago
parent
commit
7c22a3c02c
  1. 10
      Analyser/FitAnalyser.py
  2. 0
      DataContainer/MongoDB.py
  3. 4048
      Example.ipynb
  4. 1378
      test.ipynb
  5. 143
      testMongoDB.ipynb

10
Analyser/FitAnalyser.py

@ -338,7 +338,7 @@ class DensityProfileBEC2dModel(Model):
self.set_param_hint('condensate_fraction', expr=f'{self.prefix}BEC_amplitude / ({self.prefix}BEC_amplitude + {self.prefix}thermal_amplitude)')
def guess(self, data, x, y, negative=False, pureBECThreshold=0.5, **kwargs):
def guess(self, data, x, y, negative=False, pureBECThreshold=0.5, noBECThThreshold=0.0, **kwargs):
"""Estimate initial model parameter values from data."""
fitModel = TwoGaussian2dModel()
pars = fitModel.guess(data, x=x, y=y, negative=negative)
@ -359,9 +359,17 @@ class DensityProfileBEC2dModel(Model):
)
if BEC_amplitude / (thermal_amplitude + BEC_amplitude) > pureBECThreshold:
if np.abs(1 - pars_guess['A_sigmax'].value / pars_guess['A_sigmay'].value) < 0.1:
pars[f'{self.prefix}BEC_amplitude'].set(value=0)
pars[f'{self.prefix}thermal_amplitude'].set(value=(thermal_amplitude + BEC_amplitude))
else:
pars[f'{self.prefix}thermal_amplitude'].set(value=0)
pars[f'{self.prefix}BEC_amplitude'].set(value=(thermal_amplitude + BEC_amplitude))
if BEC_amplitude / (thermal_amplitude + BEC_amplitude) < noBECThThreshold:
pars[f'{self.prefix}BEC_amplitude'].set(value=0)
pars[f'{self.prefix}thermal_amplitude'].set(value=(thermal_amplitude + BEC_amplitude))
return update_param_vals(pars, self.prefix, **kwargs)

0
DataContainer/MongoDB.py

4048
Example.ipynb
File diff suppressed because one or more lines are too long
View File

1378
test.ipynb
File diff suppressed because one or more lines are too long
View File

143
testMongoDB.ipynb

@ -0,0 +1,143 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pymongo"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"mongoClient = pymongo.MongoClient()\n",
"mongoDB = mongoClient.testDB\n",
"mongoCollection = mongoDB.testCollection"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"import datetime\n",
"post = {\"author\": \"Mike\",\n",
" \"text\": \"My first blog post!\",\n",
" \"tags\": [\"mongodb\", \"python\", \"pymongo\"],\n",
" \"date\": datetime.datetime.utcnow()}"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'db' is not defined",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32mf:\\Jianshun\\analyseScript\\testMongoDB.ipynb Cell 4\u001b[0m in \u001b[0;36m1\n\u001b[1;32m----> <a href='vscode-notebook-cell:/f%3A/Jianshun/analyseScript/testMongoDB.ipynb#W6sZmlsZQ%3D%3D?line=0'>1</a>\u001b[0m posts \u001b[39m=\u001b[39m db\u001b[39m.\u001b[39mposts\n\u001b[0;32m <a href='vscode-notebook-cell:/f%3A/Jianshun/analyseScript/testMongoDB.ipynb#W6sZmlsZQ%3D%3D?line=1'>2</a>\u001b[0m post_id \u001b[39m=\u001b[39m posts\u001b[39m.\u001b[39minsert_one(post)\u001b[39m.\u001b[39minserted_id\n\u001b[0;32m <a href='vscode-notebook-cell:/f%3A/Jianshun/analyseScript/testMongoDB.ipynb#W6sZmlsZQ%3D%3D?line=2'>3</a>\u001b[0m post_id\n",
"\u001b[1;31mNameError\u001b[0m: name 'db' is not defined"
]
}
],
"source": [
"posts = mongoCollection.posts\n",
"post_id = posts.insert_one(post).inserted_id\n",
"post_id"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Task executing\n",
"\n",
"Task2 executing \n",
"\n",
"Task2 done\n",
"\n",
"Task done\n",
"\n"
]
}
],
"source": [
"from time import sleep\n",
"from multiprocessing.pool import ThreadPool\n",
" \n",
"# task executed in a worker thread\n",
"def task():\n",
" # report a message\n",
" print(f'Task executing\\n')\n",
" # block for a moment\n",
" sleep(1)\n",
" # report a message\n",
" print(f'Task done\\n')\n",
" \n",
"def task2():\n",
" # report a message\n",
" print(f'Task2 executing \\n')\n",
" # block for a moment\n",
" sleep(1)\n",
" # report a message\n",
" print(f'Task2 done\\n')\n",
" \n",
"# protect the entry point\n",
"if __name__ == '__main__':\n",
" # create and configure the thread pool\n",
" pool = ThreadPool()\n",
" # issue tasks to the thread pool\n",
" pool.apply_async(task)\n",
" pool.apply_async(task2)\n",
" # close the thread pool\n",
" pool.close()\n",
" # wait for all tasks to finish\n",
" pool.join()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "py39",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading…
Cancel
Save