Package: nuc-data-tool
Nuclear Data Automated ProcessingAn automated processing tool for specific nuclear data.DemoInstallationDependenciesnuc_tool requires:SQLAlchemy (>= 1.4.11)pandas (>= 1.2.4)toml (>= 0.10.2)protobuf (>= 3.15.8)openpyxl (>= 3.0.7)click (>= 7.1.2)pycaret (>=2.3.1)psycopg2 (>= 2.8.6)mysql-connector-python (>= 8.0.23)Set up a databasenuc-tool supports 3 different database servers and is officially supported with PostgreSQL, MySQL, and SQLite.If you’re using PostgreSQL, you’ll need the psycopg2 package.If you’re using MySQL or MariaDB, you’ll need a DB API driver like mysql-connector-python.Recommend using docker container to run database servers.You can refer these two exampledocker-composefiles.Install nuc-toolYou can install the Nuclear Data Automated Processing tool from PyPI:pipinstallnuc-data-toolThe tool is supported on Python 3.8 and above.And it is supported on postgresql(>= 13), mysql(>= 8.0)How to useTheconfig.toml(config file) is distributed with package.You can copy or download theconfigration fileinto the current working directory.it will overide the default configration.The Nuclear Data Automated Processing tool is a command line application, namednuctool>nuctool--help
Usage:python-mnuc_data_tool[OPTIONS]COMMAND[ARGS]...app命令行

Options:--versionShowtheversionandexit.--helpShowthismessageandexit.

Commands:compare对文件列表进行两两组合，进行对比，计算并输出对比结果至工作簿(xlsx文件)...extract从数据库导出选中的文件的数据到工作簿(xlsx文件)参数为文件列表(默认为所有文件)nuc_data_tool...fetch获取文件、物理量信息pop将输出文件(*.xml.out)的内容填充进数据库Populate database>nuctoolpop--help
Usage:python-mnuc_data_toolpop[OPTIONS]将输出文件(*.xml.out)的内容填充进数据库

Options:-p,--pathPATH输出文件路径，默认读取配置文件中的路径-pq,--physical_quantities[isotope|radioactivity|absorption|fission|decay_heat|gamma_spectra]物理量，默认为全部物理量-init,--initiation初始化数据库--helpShowthismessageandexit.The first step has to get those data into the database.We can specify the data file location with option-p, --path.The option-pq, --physical_quantitiescan be input multiple times. So we could focus on the physical quantities we interest in.Only those physical quantities will be get into the database.If you want a "fresh new" database, you should append the-init, --initiationoption.It will drop all tables, of course, including data, and then create all tables.>nuctoolpop-pinput_file-pqisotope-pqgamma_spectra-init
UO2Flux_CRAM_1ton_100steps:
found:['isotope']notfound:['gamma_spectra']homo-case001-006:
found:['isotope','gamma_spectra']notfound:[]View files and physical quantities>nuctoolfetch--help
Usage:python-mnuc_data_toolfetch[OPTIONS]获取文件、物理量信息

Options:-f,--file显示文件信息NOTE:Thisargumentismutuallyexclusivewitharguments:[physical_quantity].-p,--physical_quantity显示物理量信息NOTE:Thisargumentismutuallyexclusivewitharguments:[files].-l,--list以数组形式输出--helpShowthismessageandexit.This command is greatly straightforward.The-f, --fileoption will list the file names.The-p, --physical_quantityoption will list the physical quantity names.Attention, they are mutually exclusive to each other.The last one,-l, --listoption could be a combination with one of the above two options.It affects the display in an array-like format.>nuctoolfetch-f
Name:UO2Flux_CRAM_1ton_100steps
Name:UO2Flux_CRAM_1ton_50steps
Name:homo-case001-006
...

>nuctoolfetch-f-l['UO2Flux_CRAM_1ton_100steps',...'homo-case001-006']>nuctoolfetch-p
Name:isotope
Name:gamma_spectra

>nuctoolfetch-p-l['isotope','gamma_spectra']Filter and extract data>nuctoolextract--help
Usage:python-mnuc_data_toolextract[OPTIONS][FILENAMES]...从数据库导出选中的文件的数据到工作簿(xlsx文件)参数为文件列表(默认为所有文件)nuc_data_toolextract'homo-case001-006''homo-case007-012''homo-case013-018'nuc_data_toolextract'homo-case001-006'文件名(没有后缀)例如：001.xml.out->001文件名列表例如：001002003Options:-p,--result_pathPATH输出文件路径，默认读取配置文件中的路径-pq,--physical_quantities[isotope|radioactivity|absorption|fission|decay_heat|gamma_spectra]物理量，默认为全部物理量-n,--nuclide[decay|fission_light|short_lives]核素列表，从配置文件nuclide_list项下读取，默认fission_light-all,--all_step提取中间步骤-m,--merge将结果合并输出至一个文件--helpShowthismessageandexit.First, let's talk about the optional argument -FILENAMES.This argument can accept as many as possible file names.If you need all of the files, you can simply ignore the argument.It will make all file names as its own arguments, which is the default behavior.We can specify the exported file location with option-p, --result_path.The option-pq, --physical_quantitiescan be input multiple times. So we could focus on the physical quantities we interest in.Only those physical quantities will be extracted with data.> nuctool extract 'homo-case097-102' 'homo-case139-144' -p result

> ls result
homo-case097-102.xlsx  homo-case139-144.xlsxWe filter data by nuclide list with-n, --nuclideoption. You can find these details in theconfig.tomlfile.Extracting all steps by using-all, --all_stepoption, if not, it just extracts the first step and the last step.>nuctoolextract'homo-case097-102''homo-case139-144'-presult-all

>lsresult
all_steps_homo-case097-102.xlsxall_steps_homo-case139-144.xlsxAppending the-m, --mergeoption, the extracted data will merge into a single file, instead of one by one file.>nuctoolextract'homo-case097-102''homo-case139-144'-presult-m
>nuctoolextract'homo-case097-102''homo-case139-144'-presult-all-m
>lsresult
all_steps_final.xlsxfinal.xlsxCompare and extract data>nuctoolcompare--help
Usage:python-mnuc_data_toolcompare[OPTIONS]REFERENCE_FILE[COMPARISON_FILES]...对文件列表进行两两组合，进行对比，计算并输出对比结果至工作簿(xlsx文件)第一个参数为基准文件，第二个参数为文件列表(默认为除基准文件以外的所有文件)nuc_data_toolcompare'homo-case001-006''homo-case007-012''homo-case013-018'nuc_data_toolcompare'homo-case001-006'文件名(没有后缀)例如：001.xml.out->001文件名列表例如：001002003Options:-p,--result_pathPATH输出文件路径，默认读取配置文件中的路径-pq,--physical_quantities[isotope|radioactivity|absorption|fission|decay_heat|gamma_spectra]物理量，默认为isotope-n,--nuclide[decay|fission_light|short_lives]核素列表，从配置文件nuclide_list项下读取-dm,--deviation_mode[relative|absolute]偏差模式，分为绝对和相对，默认为相对-t,--thresholdTEXT偏差阈值，默认1.0E-12-all,--all_step提取中间步骤--helpShowthismessageandexit.The last but not least command, we used to compare and extract data.Like the former command, arguments first.There are two arguments.One,REFERENCE_FILEthe first argument, is a required argument,and the other one,COMPARISON_FILESthe rest of arguments, is a variadic argument - more specifically, it can accept an unlimited number of arguments.A little bit difference withFILENAMESargument, the default value ofCOMPARISON_FILESargument is all of file names, exceptREFERENCE_FILEargument's value.You can set one file name as theREFERENCE_FILE, and skip theCOMPARISON_FILES.The nuctool program will compare all rest of the files with the reference file one by one.We can specify the exported file location with option-p, --result_path.The option-pq, --physical_quantitiescan be input multiple times. So we could focus on the physical quantities we interest in.Only those physical quantities will be campared and extracted.>nuctoolcompare'UO2Flux_CRAM_1ton_50steps''homo-case007-012''homo-case013-018'-presult('UO2Flux_CRAM_1ton_50steps','homo-case007-012')('UO2Flux_CRAM_1ton_50steps','homo-case013-018')('homo-case007-012','homo-case013-018')>lsresult/comparative_result
relative_1.0E-12_homo-case007-012_vs_homo-case013-018.xlsx
relative_1.0E-12_UO2Flux_CRAM_1ton_50steps_vs_homo-case007-012.xlsx
relative_1.0E-12_UO2Flux_CRAM_1ton_50steps_vs_homo-case013-018.xlsxLike the former one, we filter data by nuclide list with-n, --nuclideoption. You can find these details in theconfig.tomlfile.Same, extracting all steps by using-all, --all_stepoption, if not, it just extracts the first step and the last step.>nuctoolcompare'UO2Flux_CRAM_1ton_50steps''homo-case007-012''homo-case013-018'-presult-all('UO2Flux_CRAM_1ton_50steps','homo-case007-012')('UO2Flux_CRAM_1ton_50steps','homo-case013-018')('homo-case007-012','homo-case013-018')>lsresult/comparative_result
all_step_relative_1.0E-12_homo-case007-012_vs_homo-case013-018.xlsx
all_step_relative_1.0E-12_UO2Flux_CRAM_1ton_50steps_vs_homo-case007-012.xlsx
all_step_relative_1.0E-12_UO2Flux_CRAM_1ton_50steps_vs_homo-case013-018.xlsxThere are two deviation mode of calculation. The one is relative mode, the other one is absolute mode.We use-dm, --deviation_modeoption to choose one of them.>nuctoolcompare'UO2Flux_CRAM_1ton_50steps''homo-case007-012''homo-case013-018'-presult-dmabsolute('UO2Flux_CRAM_1ton_50steps','homo-case007-012')('UO2Flux_CRAM_1ton_50steps','homo-case013-018')('homo-case007-012','homo-case013-018')>lsresult/comparative_result
absolute_1.0E-12_homo-case007-012_vs_homo-case013-018.xlsx
absolute_1.0E-12_UO2Flux_CRAM_1ton_50steps_vs_homo-case007-012.xlsx
absolute_1.0E-12_UO2Flux_CRAM_1ton_50steps_vs_homo-case013-018.xlsxThe-t, --thresholdoption defines the threshold value of calculation.The default value is1.0E-12. I think maybe not touching it is a good idea.>nuctoolcompare'UO2Flux_CRAM_1ton_50steps''homo-case007-012''homo-case013-018'-presult-dmabsolute-t1.0E-10('UO2Flux_CRAM_1ton_50steps','homo-case007-012')('UO2Flux_CRAM_1ton_50steps','homo-case013-018')('homo-case007-012','homo-case013-018')>lsresult/comparative_result
absolute_1.0E-10_homo-case007-012_vs_homo-case013-018.xlsx
absolute_1.0E-10_UO2Flux_CRAM_1ton_50steps_vs_homo-case007-012.xlsx
absolute_1.0E-10_UO2Flux_CRAM_1ton_50steps_vs_homo-case013-018.xlsxImport as a package.You can also call the Nuclear Data Automated Processing tool in your own Python code, by importing from thenuc_data_toolpackage:>>>fromnuc_data_tool.db.fetch_dataimportfetch_files_by_name>>>forfileinfetch_files_by_name('all'):...print(file.name)...UO2Flux_CRAM_1ton_100stepsUO2Flux_CRAM_1ton_10stepsUO2Flux_CRAM_1ton_50stepshomo-case001-006homo-case007-012homo-case013-018...