zoukankan      html  css  js  c++  java
  • IDL——where函数的学习

    1.where的基本用法

    函数WHERE()能返回数组中满足指定条件的元素下标

    调用格式:

    Result=Where(数组表达式[,count][,Complement=变量1][,/L64][,NCOMPLEMENT=变量2])

    其中,关键字count返回符合指定条件的元素个数;变量1为不满足条件的数组元素下标;变量2为不满足条件的数组元素个数

    eg:

    IDL> a=[[1,2],[3,4]]
    IDL> print,a
    1 2
    3 4

    IDL> c=where(a ge 2, count)
    IDL> print,count         ;count:对应于a中大于等于2的元素个数
    3

    2.使用where返回对应数值的二维坐标

    result 返回的是一维的坐标

    要想返回二维坐标,需要使用array_indices函数

    eg:

    a=[[1,2],[3,4]]
    IDL> print,a
    1 2
    3 4
    IDL> pos=where(a eq 3)
    IDL> print,pos
    2
    IDL> qc_dims=size(a,/dimensions)
    IDL> pos2=array_indices(qc_dims,pos,/dimensions)     ;pos2对应于值为3的二维坐标
    IDL> print,pos2
    0 1
    IDL> print,a[pos2[0],pos2[1]]
    3

    备注:学习的相关内容是从链接:https://www.cnblogs.com/wintertone/p/6596672.html  摘出来的,为了方便整理就写在自己的博客园中。

  • 相关阅读:
    2017.5.5上午学习内容
    2017.5.4下午学习内容
    2017.5.4上午学习内容
    2017.5.3上午学习内容
    2017.4.28下午学习内容
    2017.4.28上午学习内容
    scrapy项目的代码书写流程
    pycharm的远程连接
    mongodb的安装---linux篇
    mongo的安装和使用---windows篇
  • 原文地址:https://www.cnblogs.com/gegemu/p/9909628.html
Copyright © 2011-2022 走看看