本文整理汇总了C++中adcontrols::MassSpectrum::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ MassSpectrum::resize方法的具体用法?C++ MassSpectrum::resize怎么用?C++ MassSpectrum::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类adcontrols::MassSpectrum
的用法示例。
在下文中一共展示了MassSpectrum::resize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SamplingInfo
bool
MappedSpectrum::transform( adcontrols::MassSpectrum& ms ) const
{
auto& prop = ms.getMSProperty();
int32_t nDelay = int32_t( ( delay_ / sampInterval_ ) + 0.5 );
auto si = SamplingInfo( sampInterval_, delay_, nDelay, nSamples_, num_average_, 0 /* mode */ );
si.fSampInterval( sampInterval_ );
prop.setSamplingInfo( si );
prop.setNumAverage( num_average_ );
prop.setTrigNumber( trig_number_, trig_number_origin_ );
prop.setTimeSinceEpoch( timeSinceEpoch_.second );
ms.resize( data_.size() );
ms.setCentroid( adcontrols::CentroidNative );
//auto scanlaw = prop.scanLaw();
for ( size_t idx = 0; idx < data_.size(); ++idx ) {
double tof = this->time( idx );
ms.setTime( idx, tof );
//if ( scanlaw )
// ms.setMass( idx, ms.compute_mass( data_[ idx ].first ) );
ms.setIntensity( idx, data_[ idx ].second );
}
return true;
}
示例2: info
bool
TimeDigitalHistogram::translate( adcontrols::MassSpectrum& sp
, const TimeDigitalHistogram& hgrm )
{
sp.setCentroid( adcontrols::CentroidNative );
using namespace adcontrols::metric;
// ext_trig_delay should be managed before came here. (ex. histogram::move())
double ext_trig_delay = hgrm.this_protocol_.delay_pulses().at( adcontrols::TofProtocol::EXT_ADC_TRIG ).first;
adcontrols::MSProperty prop;
adcontrols::SamplingInfo info( hgrm.xIncrement()
, hgrm.initialXOffset() + ext_trig_delay
, int32_t( ( hgrm.initialXOffset() + ext_trig_delay ) / hgrm.xIncrement() ) // delay
, uint32_t( hgrm.actualPoints() ) // this is for acq. time range calculation
, uint32_t( hgrm.trigger_count() )
, hgrm.this_protocol_.mode() /* mode */);
prop.setAcceleratorVoltage( 0 ); // empty
prop.setSamplingInfo( info );
prop.setTimeSinceInjection( hgrm.initialXTimeSeconds() );
prop.setTimeSinceEpoch( hgrm.timeSinceEpoch().first );
prop.setNumAverage( uint32_t( hgrm.trigger_count() ) );
prop.setTrigNumber( uint32_t( hgrm.serialnumber().first ) );
prop.setDataInterpreterClsid( "adcontrols::TimeDigitalHistogram" );
TimeDigitalHistogram::device_data data( hgrm.this_protocol_ );
std::string ar;
adportable::binary::serialize<>()( data, ar );
prop.setDeviceData( ar.data(), ar.size() );
sp.setMSProperty( prop );
size_t size = hgrm.size();
sp.resize( size );
size_t idx = 0;
for ( auto it = hgrm.begin(); it != hgrm.end(); ++it, ++idx ) {
sp.setTime( idx, it->first );
sp.setIntensity( idx, it->second );
}
return true;
}
示例3: if
//virtual
bool
datafile::getSpectrum( int fcn, size_t pos, adcontrols::MassSpectrum& ms, uint32_t objId ) const
{
(void)fcn;
try {
EDAL::IMSSpectrumCollectionPtr pSpectra = pAnalysis_->GetMSSpectrumCollection();
EDAL::IMSSpectrumPtr pSpectrum = pSpectra->GetItem( long(pos) + 1 ); // 1-origin
if ( pSpectrum->Polarity == EDAL::SpectrumPolarity::IonPolarity_Negative )
ms.setPolarity( adcontrols::MS_POLARITY::PolarityNegative );
else if ( pSpectrum->Polarity == EDAL::SpectrumPolarity::IonPolarity_Positive )
ms.setPolarity( adcontrols::MS_POLARITY::PolarityPositive );
else
ms.setPolarity( adcontrols::MS_POLARITY::PolarityIndeterminate );
adcontrols::MSProperty prop = ms.getMSProperty();
prop.setTimeSinceInjection( static_cast< unsigned long >( pSpectrum->RetentionTime /* sec */ * 1.0e6 ) ); // usec
ms.setMSProperty( prop ); // <- end of prop set
_variant_t vMasses, vIntens;
if ( objId <= 1 ) {
pSpectrum->GetMassIntensityValues( EDAL::SpectrumType_Profile, &vMasses, &vIntens );
ms.setCentroid( adcontrols::CentroidNone ); // profile
} else { // objId should be 2
pSpectrum->GetMassIntensityValues( EDAL::SpectrumType_Line, &vMasses, &vIntens );
ms.setCentroid( adcontrols::CentroidNative );
}
SafeArray sa_masses( vMasses );
ms.resize( sa_masses.size() );
ms.setMassArray( reinterpret_cast< const double *>( sa_masses.p() ) );
SafeArray sa_intensities( vIntens );
ms.setIntensityArray( reinterpret_cast< const double *>( sa_intensities.p() ) );
ms.setAcquisitionMassRange( ms.getMass( 0 ), ms.getMass( ms.size() - 1 ) );
return true;
} catch(_com_error& ex ) {
ADERROR() << std::wstring( ex.ErrorMessage() );
return false;
}
return false;
}
示例4: int
//virtual
bool
datafile::getSpectrum( int /* fcn*/, size_t idx, adcontrols::MassSpectrum& ms, uint32_t /* objid */) const
{
if ( unsigned( idx ) < spcfile_->number_of_subfiles() ) {
const galactic::spchdr& hdr = *spcfile_->spchdr();
const galactic::subhdr& sub = *spcfile_->subhdr( idx );
std::pair< double, double > range = std::make_pair( hdr.ffirst(), hdr.flast() );
const size_t npts = hdr.fnpts();
ms.resize( npts );
ms.setAcquisitionMassRange( range.first, range.second );
for ( size_t i = 0; i < npts; ++i ) {
ms.setMass( int(i), i * double(( range.second - range.first )) / ( npts - 1 ) + range.first );
ms.setIntensity( int(i), sub[i] );
}
return true;
}
return false;
}
示例5:
//virtual
bool
datafile::getSpectrum( int /* fcn*/, size_t idx, adcontrols::MassSpectrum& ms, uint32_t /* objid */) const
{
if ( lrpfile_ && unsigned( idx ) < lrpfile_->number_of_spectra() ) {
if ( auto msdata = (*lrpfile_)[ idx ] ) {
std::vector< double > time, intens;
if ( lrpfile_->getMS( *msdata, time, intens ) ) {
ms.resize( time.size() );
ms.setMassArray( time.data() );
ms.setIntensityArray( intens.data() );
ms.setAcquisitionMassRange( time.front(), time.back() );
return true;
}
}
}
return false;
}
示例6:
adcontrols::translate_state
DataInterpreter::translate_profile( adcontrols::MassSpectrum& ms
, const char * data, size_t dsize
, const char * meta, size_t msize
, const adcontrols::MassSpectrometer& spectrometer
, size_t idData ) const
{
(void)idData;
adportable::debug(__FILE__, __LINE__) << "translate_profile( dsize=" << dsize << ", msize=" << msize << ")";
import_profile profile;
import_continuum_massarray ma;
const batchproc::MassSpectrometer* pSpectrometer = dynamic_cast< const batchproc::MassSpectrometer * >( &spectrometer );
if ( pSpectrometer == 0 )
return adcontrols::translate_error;
if ( adportable::bzip2::is_a( data, dsize ) ) {
std::string ar;
adportable::bzip2::decompress( ar, data, dsize );
adportable::debug(__FILE__, __LINE__) << "translate_profile deserialize import_profile w/ decompress";
if ( ! adportable::serializer< import_profile >::deserialize( profile, ar.data(), ar.size() ) )
return adcontrols::translate_error;
} else {
adportable::debug(__FILE__, __LINE__) << "translate_profile deserialize import_profile w/o decompress";
if ( ! adportable::serializer< import_profile >::deserialize( profile, data, dsize ) )
return adcontrols::translate_error;
}
if ( meta && msize ) {
if ( adportable::bzip2::is_a( meta, msize ) ) {
std::string ar;
adportable::bzip2::decompress( ar, meta, msize );
if ( ! adportable::serializer< import_continuum_massarray >::deserialize( ma, ar.data(), ar.size() ) )
return adcontrols::translate_error;
} else {
if ( ! adportable::serializer< import_continuum_massarray >::deserialize( ma, meta, msize ) )
return adcontrols::translate_error;
}
}
adportable::debug(__FILE__, __LINE__) << "translate_profile checkpoint 3";
const import_continuum_massarray& continuum_massarray = meta ? ma : pSpectrometer->continuum_massarray();
ms.setMSProperty( profile.prop_ );
ms.setPolarity( profile.polarity_ );
ms.resize( profile.intensities_.size() );
adportable::debug(__FILE__, __LINE__) << "translate_profile checkpoint 4";
ms.setMassArray( continuum_massarray.masses_.data() );
auto intens = profile.intensities_.data();
for ( size_t i = 0; i < ms.size(); ++i )
ms.setIntensity( i, *intens++ );
adportable::debug(__FILE__, __LINE__) << "translate_profile checkpoint 5";
ms.setAcquisitionMassRange( ms.getMass( 0 ), ms.getMass( ms.size() - 1 ) );
adportable::debug(__FILE__, __LINE__) << "translate_profile checkpoint 6";
return adcontrols::translate_complete;
}