npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

xrd-calculate

v0.0.1

Published

Calculate xrd data

Downloads

2

Readme

@xtalpi/xrd-calculate

XRD计算

安装

npm i @xtalpi/xrd-calculate --save

使用

引入模块

ES6 import 引入

import { Calculate } from '@xtalpi/xrd-calculate'

CommonJs require 引入

const { Calculate } = require('@xtalpi/xrd-calculate')

基本用法

const filepath = 'your-file-path'
const calculate = new Calculate()
calculate.onInitialized()
  .then(() => {
    // 调用实例方法
    calculate.ciftoXrd(filepath)
      .then(xrdDatas => {
        console.log(xrdDatas)
      })
      .catch(err => { throw err })
  })
  .catch(err => { throw err })

API

calculate.cifToXrd (filepath, options)

  /**
   * @function 解析cif文件,转换为xrd数据
   * @param {String} filepath cif文件路径 
   * @param {Object} options 可选项
   *                 - theta2Min {Number} 2theta的最小值, 默认为0
   *                 - theta2Max {Number} 2theta的最大值, 默认为50
   *                 - raySource {String} 射线源,默认为'CuKa1'
   *                 - smooth {Boolean} 是否进行平滑降噪处理, 默认为true
   *                 - smoothStep {Number} 平滑处理的步进, 默认为0.02
   *                 - scaled {Boolean} 是否将intensity转换为相对百分比, 默认为false
   *                 - decimalX {Number} 2theta值的小数位精度, 默认为原始值
   *                 - decimalY {Number} intensity值的小数位精度, 默认为原始值
   *                 - dataFormat {String} 返回的单个数据项格式,可选值:object/array。默认为'object',即:[{x:3,y:100},{x:4,y:100.5}...]
   * @return {Promise} 成功:resolve(xrdData), xrdData为转换后的结果。失败:reject(error)
   */

calculate.smooth (xrdArray, options)

  /**
   * @function 对xrd数据进行平滑降噪处理
   * @param {Array} xrdArray xrd数据,如:[[3,100],[4,100.5]...]
   * @param {Object} options 可选项
   *                 - theta2Min {Number} 2theta的最小值, 默认为0
   *                 - theta2Max {Number} 2theta的最大值, 默认为50
   *                 - smoothStep {Number} 平滑处理的步进, 默认为0.02
   *                 - scaled {Boolean} 是否将intensity转换为相对百分比, 默认为false
   *                 - yIndex {Number} 取xrdArray中单个数据项的第几个作为intensity, 默认为1,即取[3,100]中的100作为intensity值
   *                 - update {Boolean} 是否用平滑后的数据更新xrdArray, 默认为false,即不更新
   * @return {Promise} 成功:resolve(result), 当update为false时,result为平滑后的xrd数据;当update为true时,result为更新后的xrdArray。失败:reject(error)
   */

calculate.normalize (xrdArray, options)

  /**
   * @function 对xrd数据进行归一化处理
   * @param {Array} xrdArray xrd数据,如:[[3,100],[4,100.5]...]
   * @param {Object} options 可选项
   *                 - decimal {Number} 归一化后的数据精度(小数点后的位数),默认为3
   *                 - yIndex {Number} 取xrdArray中单个数据项的第几个作为intensity, 默认为1,即取[3,100]中的100作为intensity值
   *                 - update {Boolean} 是否用归一化后的数据更新xrdArray, 默认为false,即不更新
   * @return {Array} 返回归一化后的结果。update为false时返回新数组,update为true时返回处理后的输入数组
   */

测试

npm run test