diff --git a/cfel_cxi.py b/cfel_cxi.py index c22de90276a2790760247788316018db1897c420..7263d45946e83963d7d4cd0600c34aca41424456 100644 --- a/cfel_cxi.py +++ b/cfel_cxi.py @@ -339,6 +339,37 @@ class CXIWriter: self._fh[path] = link_target + + def create_link_to_group(self, group, path, overwrite=False): + """Creates a link to an HDF5 group. + + Creates a link to an HDF5 group (as opposed to a simple entry or stack). If a link or entry already exists at + the specified path, it is deleted and replaced only if the value of the overwrite parameter is True. + + Args: + + group (str): internal HDF5 path of the group to which the link points. + + path (str): path in the hdf5 where the link is created. + + overwrite (bool): if set to True, an entry already existing at the same location will be overwritten. If set + to False, an attempt to overwrite an entry will raise an error. + """ + + if path in self._fh: + if overwrite is True: + del (self._fh[path]) + else: + raise RuntimeError('Cannot create the link. An entry already exists at the specified path.') + + try: + link_target = self._fh[path] + except KeyError: + raise RuntimeError('Cannot create the link. The group to which the link points does not exist.') + + self._fh[path] = link_target + + def initialize_stacks(self): """Initializes the stacks. diff --git a/doc/build/doctrees/cfelpyutils.doctree b/doc/build/doctrees/cfelpyutils.doctree index d20c196e8140646916f49a4862935b4710a56c58..ae9ba9df5c4e2d3ac777db7a9cf2d7936b0bafc2 100644 Binary files a/doc/build/doctrees/cfelpyutils.doctree and b/doc/build/doctrees/cfelpyutils.doctree differ diff --git a/doc/build/doctrees/environment.pickle b/doc/build/doctrees/environment.pickle index bda2f347e036c125b45d598eb65d65b5a68bc64d..f62090d6751e80b59d170fdca8486f3d1b9c6d77 100644 Binary files a/doc/build/doctrees/environment.pickle and b/doc/build/doctrees/environment.pickle differ diff --git a/doc/build/html/cfelpyutils.html b/doc/build/html/cfelpyutils.html index da0413472d92005e4ffc80d36273129a846df28e..7e5d6271057b3f00121d334b046fe71cb23778f1 100644 --- a/doc/build/html/cfelpyutils.html +++ b/doc/build/html/cfelpyutils.html @@ -262,6 +262,28 @@ value of the overwrite parameter is True.</p> </table> </dd></dl> +<dl class="method"> +<dt id="cfelpyutils.cfel_cxi.CXIWriter.create_link_to_group"> +<code class="descname">create_link_to_group</code><span class="sig-paren">(</span><em>group</em>, <em>path</em>, <em>overwrite=False</em><span class="sig-paren">)</span><a class="headerlink" href="#cfelpyutils.cfel_cxi.CXIWriter.create_link_to_group" title="Permalink to this definition">¶</a></dt> +<dd><p>Creates a link to an HDF5 group.</p> +<p>Creates a link to an HDF5 group (as opposed to a simple entry or stack). If a link or entry already exists at +the specified path, it is deleted and replaced only if the value of the overwrite parameter is True.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> +<li><strong>group</strong> (<em>str</em>) – internal HDF5 path of the group to which the link points.</li> +<li><strong>path</strong> (<em>str</em>) – path in the hdf5 where the link is created.</li> +<li><strong>overwrite</strong> (<em>bool</em>) – if set to True, an entry already existing at the same location will be overwritten. If set</li> +<li><strong>False</strong><strong>, </strong><strong>an attempt to overwrite an entry will raise an error.</strong> (<em>to</em>) – </li> +</ul> +</td> +</tr> +</tbody> +</table> +</dd></dl> + <dl class="method"> <dt id="cfelpyutils.cfel_cxi.CXIWriter.file_is_full"> <code class="descname">file_is_full</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#cfelpyutils.cfel_cxi.CXIWriter.file_is_full" title="Permalink to this definition">¶</a></dt> diff --git a/doc/build/html/genindex.html b/doc/build/html/genindex.html index d25378c802b3e3db1392edc64b9efacd29a04817..0fba7bfb94fd95cfa307cf464eb716dc0504c376 100644 --- a/doc/build/html/genindex.html +++ b/doc/build/html/genindex.html @@ -116,10 +116,10 @@ </li> <li><a href="cfelpyutils.html#module-cfelpyutils.cfel_geom">cfelpyutils.cfel_geom (module)</a> </li> - </ul></td> - <td style="width: 33%; vertical-align: top;"><ul> <li><a href="cfelpyutils.html#module-cfelpyutils.cfel_hdf5">cfelpyutils.cfel_hdf5 (module)</a> </li> + </ul></td> + <td style="width: 33%; vertical-align: top;"><ul> <li><a href="cfelpyutils.html#module-cfelpyutils.cfel_optarg">cfelpyutils.cfel_optarg (module)</a> </li> <li><a href="cfelpyutils.html#module-cfelpyutils.cfel_psana">cfelpyutils.cfel_psana (module)</a> @@ -127,6 +127,8 @@ <li><a href="cfelpyutils.html#cfelpyutils.cfel_cxi.CXIWriter.close_file">close_file() (cfelpyutils.cfel_cxi.CXIWriter method)</a> </li> <li><a href="cfelpyutils.html#cfelpyutils.cfel_cxi.CXIWriter.create_link">create_link() (cfelpyutils.cfel_cxi.CXIWriter method)</a> +</li> + <li><a href="cfelpyutils.html#cfelpyutils.cfel_cxi.CXIWriter.create_link_to_group">create_link_to_group() (cfelpyutils.cfel_cxi.CXIWriter method)</a> </li> <li><a href="cfelpyutils.html#cfelpyutils.cfel_cxi.CXIWriter">CXIWriter (class in cfelpyutils.cfel_cxi)</a> </li> diff --git a/doc/build/html/objects.inv b/doc/build/html/objects.inv index c8846c95d119c07b2abfe116191d16e6511d0095..8ee46f78e15a12170b6850d5ea93acc4751f053c 100644 Binary files a/doc/build/html/objects.inv and b/doc/build/html/objects.inv differ diff --git a/doc/build/html/searchindex.js b/doc/build/html/searchindex.js index dae648c764a8757b839428c9876752cb15ff7ad3..5f77a38db20705c5be4f461da8b4e7a7c0d2862b 100644 --- a/doc/build/html/searchindex.js +++ b/doc/build/html/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["cfelpyutils","index","modules"],envversion:51,filenames:["cfelpyutils.rst","index.rst","modules.rst"],objects:{"":{cfelpyutils:[0,0,0,"-"]},"cfelpyutils.cfel_crystfel":{load_crystfel_geometry:[0,1,1,""]},"cfelpyutils.cfel_cxi":{CXIWriter:[0,2,1,""]},"cfelpyutils.cfel_cxi.CXIWriter":{add_stack_to_writer:[0,3,1,""],append_data_to_stack:[0,3,1,""],close_file:[0,3,1,""],create_link:[0,3,1,""],file_is_full:[0,3,1,""],get_file_handle:[0,3,1,""],initialize_stacks:[0,3,1,""],stacks_are_initialized:[0,3,1,""],write_simple_entry:[0,3,1,""],write_stack_slice_and_increment:[0,3,1,""]},"cfelpyutils.cfel_fabio":{read_cbf_from_stream:[0,1,1,""]},"cfelpyutils.cfel_geom":{apply_geometry_from_file:[0,1,1,""],apply_geometry_from_pixel_maps:[0,1,1,""],pixel_maps_for_image_view:[0,1,1,""],pixel_maps_from_geometry_file:[0,1,1,""]},"cfelpyutils.cfel_hdf5":{load_nparray_from_hdf5_file:[0,1,1,""]},"cfelpyutils.cfel_optarg":{parse_parameters:[0,1,1,""]},"cfelpyutils.cfel_psana":{dirname_from_source_runs:[0,1,1,""],psana_event_inspection:[0,1,1,""],psana_obj_from_string:[0,1,1,""]},cfelpyutils:{cfel_crystfel:[0,0,0,"-"],cfel_cxi:[0,0,0,"-"],cfel_fabio:[0,0,0,"-"],cfel_geom:[0,0,0,"-"],cfel_hdf5:[0,0,0,"-"],cfel_optarg:[0,0,0,"-"],cfel_psana:[0,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","function","Python function"],"2":["py","class","Python class"],"3":["py","method","Python method"]},objtypes:{"0":"py:module","1":"py:function","2":"py:class","3":"py:method"},terms:{"boolean":0,"case":0,"class":0,"default":0,"float":0,"function":0,"import":0,"int":0,"new":0,"return":0,"true":0,For:0,Its:0,THe:0,The:0,Use:0,about:0,access:0,accord:0,across:0,add:0,add_stack_to_writ:0,added:0,adher:0,after:0,again:0,against:0,all:0,allow:0,allowa:0,alreadi:0,also:0,amost:0,ani:0,anoth:0,api:0,appear:0,append:0,append_data_to_stack:0,appli:0,apply_geometry_from_fil:0,apply_geometry_from_pixel_map:0,are_stacks_initi:[],argument:0,arrai:0,assign:0,attempt:0,attribut:0,automat:0,axes:0,backcspad:0,base:0,beam:0,been:0,befor:0,block:0,bool:0,brace:0,bracket:0,buffer:0,build:0,can:0,cannot:0,cbf_obj:0,cbfimag:0,center:0,cfel:0,cfel_crystfel:2,cfel_cxi:2,cfel_fabio:2,cfel_geom:2,cfel_hdf5:2,cfel_optarg:2,cfel_psana:2,cfelfabio:0,cfelgeom:0,cfelhdf5:0,cfeloptarg:0,cfelpsana:0,chang:0,characterist:0,check:0,choic:0,chuck:0,chunk:0,chunk_siz:0,close:0,close_fil:0,command:0,compress:0,comput:0,config:0,configpars:0,configur:0,contain:0,content:[1,2],convers:0,convert:0,coordin:0,corner:0,correct:0,count:0,counter1:0,counter2:0,cours:0,cover:0,creat:0,create_link:0,crystfel:0,crystfel_geometri:0,cxi:0,cxidb:0,cxiwrit:0,cxix:0,data:0,data_as_slab:0,data_filenam:0,data_group:0,defin:0,delet:0,describ:0,detector1:0,detector2:0,detector:0,detector_1:0,detectorname1:0,detectorname2:0,determin:0,dict:0,dictionari:0,directori:0,dirnam:0,dirname_from_source_run:0,distanc:0,document:0,doubl:0,dtype:0,dure:0,each:0,end:0,ensur:0,entri:0,entry_1:0,error:0,etc:0,event:0,exampl:0,exist:0,exp:0,expand:0,extract:0,fabio:0,fals:0,file:0,file_is_ful:0,filenam:0,first:0,fix:0,fnam:0,follow:0,form:0,format:0,frame:0,from:0,frontcspad:0,full:0,further:0,gener:0,geometri:0,geometry_filenam:0,get:0,get_detector_geometry_2:0,get_file_handl:0,h5py:0,handl:0,has:0,have:0,hdf5:0,hold:0,html:0,http:0,identifi:0,im_out:0,imag:0,imageview:0,img_shap:0,implement:0,index:1,inform:0,initi:0,initial_data:0,initialize_stack:0,input:0,inspect:0,instanc:0,instanti:0,instead:0,integ:0,interact:0,intern:0,interoper:0,interpret:0,keep:0,kei:0,layout:0,left:0,level:0,like:0,line:0,link:0,list:0,load:0,load_crystfel_geometri:0,load_nparray_from_hdf5_fil:0,locat:0,low:0,make:0,manag:0,mani:0,manual:0,map:0,match:0,max_num_slic:0,maximum:0,miss:0,mod:0,modul:[1,2],monitor_param:0,more:0,multi:0,must:0,nake:0,name:0,ndarrai:0,need:0,never:0,next:0,non:0,none:0,nonetyp:0,normal:0,nparrai:0,number:0,number_of_entri:0,numpi:0,object:0,onc:0,one:0,onli:0,open:0,oper:0,option:0,order:0,org:0,origin:0,otherwis:0,out:0,output:0,overwrit:0,overwritten:0,own:0,p11:0,packag:2,page:1,paramet:0,pars:0,parse_paramet:0,parser:0,path:0,payload:0,petraiii:0,physic:0,pixel:0,pixel_maps_for_image_view:0,pixel_maps_from_geometry_fil:0,point:0,prefix:0,previou:0,print:0,process:0,project:0,provid:0,psana:0,psana_event_inspect:0,psana_obj_from_str:0,pyqtgraph:0,python:0,quot:0,rai:0,rais:0,rand:0,random:0,rang:[],rawconfigpars:0,read:0,read_cbf_from_stream:0,receiv:0,refer:0,reimplement:0,relev:0,replac:0,represent:0,reset:0,respect:0,risk:0,rule:0,same:0,search:1,see:0,sender:0,set:0,sever:0,shape:0,simpl:0,singl:0,size:0,slab:0,slab_shap:0,slice:0,softwar:0,sourc:0,specifi:0,squar:0,stack:0,stacks_are_initi:0,start:0,statu:0,str:0,stream:0,string:0,structur:0,style:0,subdirectori:0,submodul:2,subsequ:0,succe:0,sure:0,sync:0,synchron:0,system:0,take:0,test1:0,test2:0,tfel:0,than:0,thei:0,them:0,thi:0,time:0,top:0,tri:0,tupl:0,turn:0,type:0,uncorrect:0,union:0,unless:0,usag:0,use:0,used:0,user:0,using:0,util:0,valid:0,valu:0,verbatim:0,visual:0,wai:0,want:0,what:0,where:0,which:0,widget:0,without:0,word:0,work:0,write:0,write_simple_entri:0,write_slice_and_incr:0,write_stack_slice_and_incr:0,writer:0,written:0,www:0,your:0},titles:["cfelpyutils package","Welcome to cfelpyutils’s documentation!","cfelpyutils"],titleterms:{cfel_crystfel:0,cfel_cxi:0,cfel_fabio:0,cfel_geom:0,cfel_hdf5:0,cfel_optarg:0,cfel_psana:0,cfelfabio:[],cfelgeom:[],cfelhdf5:[],cfeloptarg:[],cfelpsana:[],cfelpyutil:[0,1,2],content:0,document:1,indic:1,modul:0,packag:0,submodul:0,tabl:1,welcom:1}}) \ No newline at end of file +Search.setIndex({docnames:["cfelpyutils","index","modules"],envversion:51,filenames:["cfelpyutils.rst","index.rst","modules.rst"],objects:{"":{cfelpyutils:[0,0,0,"-"]},"cfelpyutils.cfel_crystfel":{load_crystfel_geometry:[0,1,1,""]},"cfelpyutils.cfel_cxi":{CXIWriter:[0,2,1,""]},"cfelpyutils.cfel_cxi.CXIWriter":{add_stack_to_writer:[0,3,1,""],append_data_to_stack:[0,3,1,""],close_file:[0,3,1,""],create_link:[0,3,1,""],create_link_to_group:[0,3,1,""],file_is_full:[0,3,1,""],get_file_handle:[0,3,1,""],initialize_stacks:[0,3,1,""],stacks_are_initialized:[0,3,1,""],write_simple_entry:[0,3,1,""],write_stack_slice_and_increment:[0,3,1,""]},"cfelpyutils.cfel_fabio":{read_cbf_from_stream:[0,1,1,""]},"cfelpyutils.cfel_geom":{apply_geometry_from_file:[0,1,1,""],apply_geometry_from_pixel_maps:[0,1,1,""],pixel_maps_for_image_view:[0,1,1,""],pixel_maps_from_geometry_file:[0,1,1,""]},"cfelpyutils.cfel_hdf5":{load_nparray_from_hdf5_file:[0,1,1,""]},"cfelpyutils.cfel_optarg":{parse_parameters:[0,1,1,""]},"cfelpyutils.cfel_psana":{dirname_from_source_runs:[0,1,1,""],psana_event_inspection:[0,1,1,""],psana_obj_from_string:[0,1,1,""]},cfelpyutils:{cfel_crystfel:[0,0,0,"-"],cfel_cxi:[0,0,0,"-"],cfel_fabio:[0,0,0,"-"],cfel_geom:[0,0,0,"-"],cfel_hdf5:[0,0,0,"-"],cfel_optarg:[0,0,0,"-"],cfel_psana:[0,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","function","Python function"],"2":["py","class","Python class"],"3":["py","method","Python method"]},objtypes:{"0":"py:module","1":"py:function","2":"py:class","3":"py:method"},terms:{"boolean":0,"case":0,"class":0,"default":0,"float":0,"function":0,"import":0,"int":0,"new":0,"return":0,"true":0,For:0,Its:0,THe:0,The:0,Use:0,about:0,access:0,accord:0,across:0,add:0,add_stack_to_writ:0,added:0,adher:0,after:0,again:0,against:0,all:0,allow:0,allowa:0,alreadi:0,also:0,amost:0,ani:0,anoth:0,api:0,appear:0,append:0,append_data_to_stack:0,appli:0,apply_geometry_from_fil:0,apply_geometry_from_pixel_map:0,are_stacks_initi:[],argument:0,arrai:0,assign:0,attempt:0,attribut:0,automat:0,axes:0,backcspad:0,base:0,beam:0,been:0,befor:0,block:0,bool:0,brace:0,bracket:0,buffer:0,build:0,can:0,cannot:0,cbf_obj:0,cbfimag:0,center:0,cfel:0,cfel_crystfel:2,cfel_cxi:2,cfel_fabio:2,cfel_geom:2,cfel_hdf5:2,cfel_optarg:2,cfel_psana:2,cfelfabio:0,cfelgeom:0,cfelhdf5:0,cfeloptarg:0,cfelpsana:0,chang:0,characterist:0,check:0,choic:0,chuck:0,chunk:0,chunk_siz:0,close:0,close_fil:0,command:0,compress:0,comput:0,config:0,configpars:0,configur:0,contain:0,content:[1,2],convers:0,convert:0,coordin:0,corner:0,correct:0,count:0,counter1:0,counter2:0,cours:0,cover:0,creat:0,create_link:0,create_link_to_group:0,crystfel:0,crystfel_geometri:0,cxi:0,cxidb:0,cxiwrit:0,cxix:0,data:0,data_as_slab:0,data_filenam:0,data_group:0,defin:0,delet:0,describ:0,detector1:0,detector2:0,detector:0,detector_1:0,detectorname1:0,detectorname2:0,determin:0,dict:0,dictionari:0,directori:0,dirnam:0,dirname_from_source_run:0,distanc:0,document:0,doubl:0,dtype:0,dure:0,each:0,end:0,ensur:0,entri:0,entry_1:0,error:0,etc:0,event:0,exampl:0,exist:0,exp:0,expand:0,extract:0,fabio:0,fals:0,file:0,file_is_ful:0,filenam:0,first:0,fix:0,fnam:0,follow:0,form:0,format:0,frame:0,from:0,frontcspad:0,full:0,further:0,gener:0,geometri:0,geometry_filenam:0,get:0,get_detector_geometry_2:0,get_file_handl:0,group:0,h5py:0,handl:0,has:0,have:0,hdf5:0,hold:0,html:0,http:0,identifi:0,im_out:0,imag:0,imageview:0,img_shap:0,implement:0,index:1,inform:0,initi:0,initial_data:0,initialize_stack:0,input:0,inspect:0,instanc:0,instanti:0,instead:0,integ:0,interact:0,intern:0,interoper:0,interpret:0,keep:0,kei:0,layout:0,left:0,level:0,like:0,line:0,link:0,list:0,load:0,load_crystfel_geometri:0,load_nparray_from_hdf5_fil:0,locat:0,low:0,make:0,manag:0,mani:0,manual:0,map:0,match:0,max_num_slic:0,maximum:0,miss:0,mod:0,modul:[1,2],monitor_param:0,more:0,multi:0,must:0,nake:0,name:0,ndarrai:0,need:0,never:0,next:0,non:0,none:0,nonetyp:0,normal:0,nparrai:0,number:0,number_of_entri:0,numpi:0,object:0,onc:0,one:0,onli:0,open:0,oper:0,oppos:0,option:0,order:0,org:0,origin:0,otherwis:0,out:0,output:0,overwrit:0,overwritten:0,own:0,p11:0,packag:2,page:1,paramet:0,pars:0,parse_paramet:0,parser:0,path:0,payload:0,petraiii:0,physic:0,pixel:0,pixel_maps_for_image_view:0,pixel_maps_from_geometry_fil:0,point:0,prefix:0,previou:0,print:0,process:0,project:0,provid:0,psana:0,psana_event_inspect:0,psana_obj_from_str:0,pyqtgraph:0,python:0,quot:0,rai:0,rais:0,rand:0,random:0,rang:[],rawconfigpars:0,read:0,read_cbf_from_stream:0,receiv:0,refer:0,reimplement:0,relev:0,replac:0,represent:0,reset:0,respect:0,risk:0,rule:0,same:0,search:1,see:0,sender:0,set:0,sever:0,shape:0,simpl:0,singl:0,size:0,slab:0,slab_shap:0,slice:0,softwar:0,sourc:0,specifi:0,squar:0,stack:0,stacks_are_initi:0,start:0,statu:0,str:0,stream:0,string:0,structur:0,style:0,subdirectori:0,submodul:2,subsequ:0,succe:0,sure:0,sync:0,synchron:0,system:0,take:0,test1:0,test2:0,tfel:0,than:0,thei:0,them:0,thi:0,time:0,top:0,tri:0,tupl:0,turn:0,type:0,uncorrect:0,union:0,unless:0,usag:0,use:0,used:0,user:0,using:0,util:0,valid:0,valu:0,verbatim:0,visual:0,wai:0,want:0,what:0,where:0,which:0,widget:0,without:0,word:0,work:0,write:0,write_simple_entri:0,write_slice_and_incr:0,write_stack_slice_and_incr:0,writer:0,written:0,www:0,your:0},titles:["cfelpyutils package","Welcome to cfelpyutils’s documentation!","cfelpyutils"],titleterms:{cfel_crystfel:0,cfel_cxi:0,cfel_fabio:0,cfel_geom:0,cfel_hdf5:0,cfel_optarg:0,cfel_psana:0,cfelfabio:[],cfelgeom:[],cfelhdf5:[],cfeloptarg:[],cfelpsana:[],cfelpyutil:[0,1,2],content:0,document:1,indic:1,modul:0,packag:0,submodul:0,tabl:1,welcom:1}}) \ No newline at end of file