COPS Example of Particle Quicklook
Created by Yongjie Huang (huangynj@gmail.com), 2024-03-23.
import cops
**********************************************************
* CCCCC OOOOO PPPPPPP SSSSSSS __|__ *
* _ . CC CC OO OO PP PP SS --*-(_)-*--*
* ( _ )_ CC OO OO PPPPPPP SSSSSSS *
*(_ _(_ ,) CC CC OO OO PP SS *
* CCCCC OOOOO PP SSSSSSS *
**********************************************************
* CLOUD OAP PROCESSING SOFTWARE (COPS) *
* (Version 0.0.1) *
* Copyright (C) 2024-2026 *
**********************************************************
* This software is free: You may redistribute and/or *
* modify it under the terms of the GNU General Public *
* License version 3 or any later version *
* (GPL-3.0-or-later). *
* *
* This software is distributed "AS IS", WITHOUT ANY *
* WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GPL-3.0-or-later license for more details: *
* https://www.gnu.org/licenses/gpl-3.0.html *
**********************************************************
cops.__version__
'0.0.1'
Fast 2DS
file_2DS = './output/spif_lvl0/processed_fast2ds_cpython.nc'
im_header = cops.io.read_spif_header(file_2DS, group='Fast2DS-H')
ds_images = cops.io.read_spif_images(file_2DS, group='Fast2DS-H')
particle_num = ds_images.sizes['Images']
for i in range(600010, 600015, 1):
# for i in range(300000, 2000000, 100000):
if i > particle_num:
break
i_image = cops.io.get_ith_particle_image(im_header, ds_images, i)
cops.plot.plot_single_particle_image_with_enclosing_shape(i_image)
ds_images
<xarray.Dataset> Size: 3GB
Dimensions: (Images: 2467180, Pixels: 2530031360, Buffers: 70734)
Dimensions without coordinates: Images, Pixels, Buffers
Data variables:
image_ns (Images) int32 10MB ...
image_sec (Images) int32 10MB ...
image (Pixels) uint8 3GB ...
image_len (Images) uint16 5MB ...
buffer_index (Images) uint32 10MB ...
buffer_sec (Buffers) int32 283kB ...
clock_counts (Images) float32 10MB ...
tas (Images) float32 10MB ...
user_temp (Images) float32 10MB ...
ps_temp (Images) float32 10MB ...ds_images['clock_counts'].plot()
[<matplotlib.lines.Line2D at 0x3035ab8f0>]
ds_images['image_sec'].plot()
# (ds_images['image_ns']/1e9).plot()
[<matplotlib.lines.Line2D at 0x304996c00>]
start_particle = 600_015
n_particle = 30
cops.io.get_multi_particle_image(im_header, ds_images, start_particle, n_particle, plot=True)
<xarray.DataArray (slice: 265, diode: 128)> Size: 34kB
array([[1, 1, 1, ..., 1, 1, 1],
[1, 1, 1, ..., 1, 1, 1],
[1, 1, 1, ..., 1, 1, 1],
...,
[1, 1, 1, ..., 1, 1, 1],
[1, 1, 1, ..., 1, 1, 1],
[1, 1, 1, ..., 1, 1, 1]], dtype=uint8)
Dimensions without coordinates: slice, diode
Attributes:
long_name: Image data of 30 particles starting from 600015-th particle
ds_images['buffer_index'][start_particle:start_particle+3].values
array([16836, 16836, 16836], dtype=uint32)
ds_images['buffer_index'].plot()
ds_images['buffer_index'].max()
<xarray.DataArray 'buffer_index' ()> Size: 4B array(70493, dtype=uint32)
ds_images['buffer_sec'].plot()
[<matplotlib.lines.Line2D at 0x3034be4e0>]
ds_images['image_sec'].plot()
[<matplotlib.lines.Line2D at 0x30339e690>]
ds_images['tas'].min(), ds_images['tas'].max(), ds_images['tas'].plot()
(<xarray.DataArray 'tas' ()> Size: 4B
array(4., dtype=float32),
<xarray.DataArray 'tas' ()> Size: 4B
array(170., dtype=float32),
[<matplotlib.lines.Line2D at 0x3033cb8f0>])
2DS
drops
file_2DS = './output/spif_lvl0/base100101000000.2DS_drops_v01.nc'
im_header = cops.io.read_spif_header(file_2DS, group='2DS-V')
ds_images = cops.io.read_spif_images(file_2DS, group='2DS-V')
particle_num = ds_images.sizes['Images']
for i in range(500, 10000, 1000):
if i > particle_num:
break
i_image = cops.io.get_ith_particle_image(im_header, ds_images, i)
cops.plot.plot_single_particle_image_with_enclosing_shape(i_image)
columns
file_2DS = './output/spif_lvl0/base100101000000.2DS_columns_v01.nc'
im_header = cops.io.read_spif_header(file_2DS, group='2DS-V')
ds_images = cops.io.read_spif_images(file_2DS, group='2DS-V')
particle_num = ds_images.sizes['Images']
for i in range(500, 10000, 1000):
if i > particle_num:
break
i_image = cops.io.get_ith_particle_image(im_header, ds_images, i)
cops.plot.plot_single_particle_image_with_enclosing_shape(i_image)
ice
file_2DS = './output/spif_lvl0/base100101000000.2DS_ice_v01.nc'
im_header = cops.io.read_spif_header(file_2DS, group='2DS-V')
ds_images = cops.io.read_spif_images(file_2DS, group='2DS-V')
particle_num = ds_images.sizes['Images']
for i in range(500, 10000, 1000):
if i > particle_num:
break
i_image = cops.io.get_ith_particle_image(im_header, ds_images, i)
cops.plot.plot_single_particle_image_with_enclosing_shape(i_image)
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros
HVPS
drops
file_ = './output/spif_lvl0/base100101000000.HVPS_drops_v01.nc'
im_header = cops.io.read_spif_header(file_, group='HVPS')
ds_images = cops.io.read_spif_images(file_, group='HVPS')
particle_num = ds_images.sizes['Images']
for i in range(500, 10000, 1000):
if i > particle_num:
break
i_image = cops.io.get_ith_particle_image(im_header, ds_images, i)
cops.plot.plot_single_particle_image_with_enclosing_shape(i_image)
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros
columns
file_ = './output/spif_lvl0/base100101000000.HVPS_columns_v01.nc'
im_header = cops.io.read_spif_header(file_, group='HVPS')
ds_images = cops.io.read_spif_images(file_, group='HVPS')
particle_num = ds_images.sizes['Images']
for i in range(500, 10000, 1000):
if i > particle_num:
break
i_image = cops.io.get_ith_particle_image(im_header, ds_images, i)
cops.plot.plot_single_particle_image_with_enclosing_shape(i_image)
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros
ice
file_ = './output/spif_lvl0/base100101000000.HVPS_ice_v01.nc'
im_header = cops.io.read_spif_header(file_, group='HVPS')
ds_images = cops.io.read_spif_images(file_, group='HVPS')
particle_num = ds_images.sizes['Images']
for i in range(500, 10000, 1000):
if i > particle_num:
break
i_image = cops.io.get_ith_particle_image(im_header, ds_images, i)
cops.plot.plot_single_particle_image_with_enclosing_shape(i_image)
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros
CAPS-CIP
drops
file_ = './output/spif_lvl0/Imagefile_20100101000000.CAPS_drops_v01.nc'
im_header = cops.io.read_spif_header(file_, group='CIP')
ds_images = cops.io.read_spif_images(file_, group='CIP')
particle_num = ds_images.sizes['Images']
for i in range(500, 10000, 1000):
if i > particle_num:
break
i_image = cops.io.get_ith_particle_image(im_header, ds_images, i)
cops.plot.plot_single_particle_image_with_enclosing_shape(i_image)
columns
file_ = './output/spif_lvl0/Imagefile_20100101000000.CAPS_columns_v01.nc'
im_header = cops.io.read_spif_header(file_, group='CIP')
ds_images = cops.io.read_spif_images(file_, group='CIP')
particle_num = ds_images.sizes['Images']
for i in range(500, 10000, 1000):
if i > particle_num:
break
i_image = cops.io.get_ith_particle_image(im_header, ds_images, i)
cops.plot.plot_single_particle_image_with_enclosing_shape(i_image)
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros
ice
file_ = './output/spif_lvl0/Imagefile_20100101000000.CAPS_ice_v01.nc'
im_header = cops.io.read_spif_header(file_, group='CIP')
ds_images = cops.io.read_spif_images(file_, group='CIP')
particle_num = ds_images.sizes['Images']
for i in range(500, 10000, 1000):
if i > particle_num:
break
i_image = cops.io.get_ith_particle_image(im_header, ds_images, i)
cops.plot.plot_single_particle_image_with_enclosing_shape(i_image)
PIP
drops
file_ = './output/spif_lvl0/Imagefile_20100101000000.PIP_drops_v01.nc'
im_header = cops.io.read_spif_header(file_, group='PIP')
ds_images = cops.io.read_spif_images(file_, group='PIP')
particle_num = ds_images.sizes['Images']
for i in range(500, 10000, 1000):
if i > particle_num:
break
i_image = cops.io.get_ith_particle_image(im_header, ds_images, i)
cops.plot.plot_single_particle_image_with_enclosing_shape(i_image)
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros
columns
file_ = './output/spif_lvl0/Imagefile_20100101000000.PIP_columns_v01.nc'
im_header = cops.io.read_spif_header(file_, group='PIP')
ds_images = cops.io.read_spif_images(file_, group='PIP')
particle_num = ds_images.sizes['Images']
for i in range(500, 10000, 1000):
if i > particle_num:
break
i_image = cops.io.get_ith_particle_image(im_header, ds_images, i)
cops.plot.plot_single_particle_image_with_enclosing_shape(i_image)
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros
/Users/huangyj/Downloads/work/CLOUD_OAP/cops_dev/COPS/cops/analysis.py:530: RuntimeWarning: divide by zero encountered in scalar divide
step_size = (maximum - d - 1) / ((d + 1) * (maximum - 1))
/Users/huangyj/Downloads/work/CLOUD_OAP/cops_dev/COPS/cops/analysis.py:532: RuntimeWarning: invalid value encountered in scalar add
new_u[j] += step_size
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros
ice
file_ = './output/spif_lvl0/Imagefile_20100101000000.PIP_ice_v01.nc'
im_header = cops.io.read_spif_header(file_, group='PIP')
ds_images = cops.io.read_spif_images(file_, group='PIP')
particle_num = ds_images.sizes['Images']
for i in range(500, 10000, 1000):
if i > particle_num:
break
i_image = cops.io.get_ith_particle_image(im_header, ds_images, i)
cops.plot.plot_single_particle_image_with_enclosing_shape(i_image)
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros
/Users/huangyj/Downloads/work/CLOUD_OAP/cops_dev/COPS/cops/analysis.py:622: RuntimeWarning: invalid value encountered in sqrt
width, height = 2 / np.sqrt(vals) # Calculate axes lengths from eigenvalues
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros
WARNING: cops.analysis: Insufficient points to fit an ellipse; at least five are required. Returning zeros