hxrc_getcbn

PURPOSE ^

HXRC_GETCBN [ tcbn, cbn, Ebin ] = hxrc_getcbn( shot, ch, t, Echan)

SYNOPSIS ^

function [ tcbn, cbn, Ebin ] = hxrc_getcbn( shot, ch, t, Echan)

DESCRIPTION ^

HXRC_GETCBN [ tcbn, cbn, Ebin ] = hxrc_getcbn( shot, ch, t, Echan)
   returns the data measured with the HXRC diagnostic, operational in the
   shot range 15574 to 39214 (camera was not present for all these shots)

 INPUT:
   shot ...... TCV shot number
   ch ........ channel (5-18 see the plasma, 1-4 and 19 are hidden)
               (default: 5-18)
   t ......... time interval, or time point to get closest data point [s]
               (default: [-Inf,Inf], means all)
   Echan ..... index of energy channels to be taken
               (default: 1:8, means all)

 OUTPUT:
   tcbn ...... time base of the measurement [s]
   cbn ....... chord brightness for the requested chords [counts/s]
   Ebin ...... energy thresholds (if Echan not all channel, the energy
               bins may not reach up to the next higher threshold) [keV]
               Remark: the raw data in the tree contains all counts above
               the threshold times 0.5, while the output of this function
               is the countrate in the energy bin from one threshold to
               the next one, with the last containing the data above the
               highest threshold.


 J. Kamleitner, Mar 2014, CRPP, EPFL

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ tcbn, cbn, Ebin ] = hxrc_getcbn( shot, ch, t, Echan)
0002 %HXRC_GETCBN [ tcbn, cbn, Ebin ] = hxrc_getcbn( shot, ch, t, Echan)
0003 %   returns the data measured with the HXRC diagnostic, operational in the
0004 %   shot range 15574 to 39214 (camera was not present for all these shots)
0005 %
0006 % INPUT:
0007 %   shot ...... TCV shot number
0008 %   ch ........ channel (5-18 see the plasma, 1-4 and 19 are hidden)
0009 %               (default: 5-18)
0010 %   t ......... time interval, or time point to get closest data point [s]
0011 %               (default: [-Inf,Inf], means all)
0012 %   Echan ..... index of energy channels to be taken
0013 %               (default: 1:8, means all)
0014 %
0015 % OUTPUT:
0016 %   tcbn ...... time base of the measurement [s]
0017 %   cbn ....... chord brightness for the requested chords [counts/s]
0018 %   Ebin ...... energy thresholds (if Echan not all channel, the energy
0019 %               bins may not reach up to the next higher threshold) [keV]
0020 %               Remark: the raw data in the tree contains all counts above
0021 %               the threshold times 0.5, while the output of this function
0022 %               is the countrate in the energy bin from one threshold to
0023 %               the next one, with the last containing the data above the
0024 %               highest threshold.
0025 %
0026 %
0027 % J. Kamleitner, Mar 2014, CRPP, EPFL
0028 
0029 if(nargin<2 || isempty(ch))
0030     ch=5:18;
0031 end
0032 if(nargin<3 || isempty(t))
0033     t=[-Inf,Inf];
0034 end
0035 if(nargin<4 || isempty(Echan))
0036     Echan=1:8;
0037 end
0038 
0039 
0040 
0041 nch=length(ch);
0042 nchan=length(Echan);
0043 
0044 mdsopen(shot);
0045 
0046 % get the energy threshold data
0047 Ebinall=mdsdata('\diagz::hxr_thresholds');
0048 Ebin=Ebinall(Echan).';
0049 
0050 % init output for case without data
0051 tcbn=NaN;
0052 cbn=NaN(nch*nchan,1);
0053 flag=true;
0054 
0055 for i=1:nch
0056     for ichan=1:nchan
0057         % read signal from nodes
0058         hxrcdata=tdi(sprintf('\\diagz::hxr_counts:chord_%03d:channel_%03d',ch(i),Echan(ichan)));
0059         if(~mod(hxrcdata.status,2)) % error reading data
0060             continue;
0061         end
0062         if(length(t)>1)
0063             ihxrctime=(hxrcdata.dim{1}>=t(1) & hxrcdata.dim{1}<=t(2));
0064         else
0065             [~,ihxrctime]=min(abs(hxrcdata.dim{1}-t));
0066         end
0067         tcbn=hxrcdata.dim{1}(ihxrctime);
0068         if(flag) % init cbn if has not been init'd
0069             cbn=NaN(nch*nchan,length(tcbn));
0070             flag=false;
0071         end
0072         % the factor of 2 is documented in the wiki, and the division is
0073         % necessary to convert from counts to countrate
0074         if(length(t)>1)
0075             cbn((ichan-1)*nch+i,:)=2*hxrcdata.data(ihxrctime)/mean(diff(tcbn));
0076         else
0077             cbn((ichan-1)*nch+i,:)=2*hxrcdata.data(ihxrctime)/mean(diff(hxrcdata.dim{1}));
0078         end
0079     end
0080 end
0081 
0082 mdsclose;
0083 
0084 % transform data from threshold to energy bin data (as for HXRS)
0085 for i=1:nch
0086     for ichan=1:(nchan-1)
0087         cbn((ichan-1)*nch+i,:)=max(cbn((ichan-1)*nch+i,:)-cbn(ichan*nch+i,:),0);
0088     end
0089 end
0090 
0091 
0092 end
0093

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.