Giter VIP home page Giter VIP logo

chama's Introduction

Chama

build Coverage Status Documentation Status Downloads

Continuous or regularly scheduled monitoring has the potential to quickly identify changes in the environment. However, even with low-cost sensors, only a limited number of sensors can be used. The physical placement of these sensors and the sensor technology used can have a large impact on the performance of a monitoring strategy.

Chama is a Python package which includes mixed-integer, stochastic programming formulations to determine sensor locations and technology that maximize the effectiveness of the detection program. The software was developed to design sensor networks for water distribution networks and airborne pollutants, but the methods are general and can be applied to a wide range of applications.

For more information, go to https://sandialabs.github.io/chama/

Citing Chama

To cite Chama, use the following reference:

  • Klise, K.A., Nicholson, B., and Laird, C.D. (2017). Sensor Placement Optimization using Chama, Sandia Report SAND2017-11472, Sandia National Laboratories.

License

Revised BSD. See the LICENSE.txt file.

Organization

Directories

  • chama - Python package
  • ci - Travis CI requirements
  • documentation - User manual

Contact

Sandia National Laboratories is a multimission laboratory managed and operated by National Technology and Engineering Solutions of Sandia, LLC., a wholly owned subsidiary of Honeywell International, Inc., for the U.S. Department of Energy's National Nuclear Security Administration under contract DE-NA-0003525.

chama's People

Contributors

blnicho avatar carldlaird avatar kaklise avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chama's Issues

Chama will run one signal csv file but not the other.

I am running Chama on two signals files. Both files were created programmatically with Python code to generate a signal file as a CSV. The signal file is the only input that is different between the two files. One file runs while the other file is giving me an error.
image
The signal files appear to be correct. Both are in the same format.
Node, Time, Data
The sensor locations are the same as is the time the same. Both are different lengths but the longer file is one that is working. The major diffrence is the values in the
I have attached part of the csv's zipped here as the files are too large even zipped to put in full. I am looking into our process of generating these files in order to fix this issue.
not working signals.zip
working signals.zip

Concentration Values change with Granularity

Running the code below with values of granularity to be 40 and 100 gives different concentration values in chama.simulation.GaussianPlume model. granularity below is a variable that tells how much finely we want to divide the volume.

Expected Output:
Similar concentration values, irrespective of the value of granularity.

Current Output:
Radically different values by just changing the granularity. I was able to get the max concentration values to be equal to S = 389.843737 for the case when granularity = 100
And S = 48.59 when granularity = 40.

# %% Imports
import numpy as np
import pandas as pd
import chama
import matplotlib.pyplot as plt
#%matplotlib inline

# %% Making a 3D grid
x_vals = (0, 40)
y_vals = x_vals
z_vals = (0, 10)
x_start = 10
y_start = x_start
z_start = 5
granularity = 40  ######### ←← Just changing this makes the concentration values fluctuate
x_grid = np.linspace(*x_vals, granularity) # this is in mts
y_grid = np.linspace(*y_vals, granularity)
z_grid = np.linspace(*z_vals, granularity)
grid = chama.simulation.Grid(x_grid, y_grid, z_grid)

# %% Defining a pollutant source with rate
source = chama.simulation.Source(x_start, y_start, z_start, rate = 3)

# %% Defining the Atmospheric Conditions (We only support x-y plane air movement)
atm = pd.DataFrame(
        {
           'Wind Direction': [45],
           'Wind Speed': [2],
           'Stability Class': ['A'],
        },
        index=[0]
      )

# %% Gives the concentrations during steady state
gauss_plume = chama.simulation.GaussianPlume(grid, source, atm)
gauss_plume.run()
signal = gauss_plume.conc
print(signal.head(5))
print(signal.tail(5))

# %%
chama.graphics.signal_convexhull(
        signal, 
        scenarios=['S'], 
        threshold=1e-5,
        x_range = x_vals, 
        y_range = y_vals, 
        z_range = z_vals
    )
print (signal.max())
plt.show()

I was hoping the value of the concentrations should not fluctuate. Is there something that I am missing here?

Thanks a lot for the help.

Concentration Values not Maximum near the source

concs

I had selected the source location as y = 20 and x = 20. I expected the Concentration values to be maximum near the source, but according to the cross-section of the concentration values, that is not being followed.

If this something that is expected, kindly accept my apologies. It would be fantastic if you could direct me to some source to study Gaussian Plumes.

Thanks a lot for your help.

Which type should be expected in _df_columns_required ?

Hello.
I am trying to run of the code samples provided in WNTR projects repository. https://github.com/USEPA/WNTR/blob/main/examples/sensor_placement.py

At a certain moment I get the following error.

Traceback (most recent call last):
  File "../main.py", line 68, in <module>
    results[n] = impactform.solve(min_det_time, sensor_characteristics,
  File "..\optimize.py", line 107, in solve
    self.create_pyomo_model(impact=impact, sensor=sensor, scenario=scenario,
  File "..\optimize.py", line 140, in create_pyomo_model
    cu._df_columns_required('impact', impact,
  File "..\chama\utils.py", line 23, in _df_columns_required
    raise TypeError('Expected column "{0}" of type {1} in DataFrame '
TypeError: Expected column "Impact" of type [<class 'numpy.float64'>, <class 'numpy.int64'>] in DataFrame "impact".

I looked at your examples (e.g. https://chama.readthedocs.io/en/stable/optimization.html) and source code. In the examples it is shown that Impact column is of (most likely) float64 type. However, in the source code it is written the following:

cu._df_columns_required('impact', impact,
                                {'Scenario': np.object,
                                 'Sensor': np.object,
                                 impact_col_name: [np.float64, np.int64]})

So the example from tutorial and a source code don't match.
What is the best way to fix it? Should I simply change to e.g. impact_col_name: np.float64? Or is there another workaround?
Thank you.

Importing an EPANET network defined in INP file format

Hi,

Is there an example somewhere about importing an INP file (defining a water network) to be used by Chama?

The closest I could find is test_examples.py that reads from a csv file. I would like to do the same, but from an INP file like

Please note that this issue is not just about file formats, but also about the data within the INP that might be different from the CSV data given in the example above. For an example, check out the benchmark Hanoi network INP description here.

Thank you,
Paul Irofti

Concentration Values become zero when we have wind-speed nearing to zero

I was playing around with the library by changing the values of parameters and I noticed that making the wind_speed close to 0 in the chama.simulation.GaussianPlume model, the concentration of the pollutants becomes zero everywhere.

For the case of wind_speed = 10.
wind10
wind10_xcross


For the case of wind_speed = 0.1.
wind0
wind0_xcross

Expected Output:
Non-zero concentration values, irrespective of the value of wind_speed. At max, the Gaussian plume would be facing upwards.

Current Output:
zero valued Concentration Values for the case when wind_speed = 0.1, but Non-zero values when wind_speed = 10.

To Reproduce:

# %% Imports
import numpy as np
import pandas as pd
import chama
import matplotlib.pyplot as plt
#%matplotlib inline

# %% Making a 3D grid
x_vals = (0, 100)
y_vals = x_vals
z_vals = (0, 100)
x_start = 50
y_start = x_start
z_start = 20
granularity = 40
x_grid = np.linspace(*x_vals, granularity) # this is in mts
y_grid = np.linspace(*y_vals, granularity)
z_grid = np.linspace(*z_vals, granularity)
grid = chama.simulation.Grid(x_grid, y_grid, z_grid)

# %% Defining a pollutant source with rate
source = chama.simulation.Source(x_start, y_start, z_start, rate = 300)

# %% Defining the Atmospheric Conditions
atm = pd.DataFrame(
        {
           'Wind Direction': [0],
           'Wind Speed': [0.1], ## ←← Changing this to 0.1 makes concenration values die.
           'Stability Class': ['C'],
        },
        index=[0]
      )

# %% Gives the concentrations during steady state
gauss_plume = chama.simulation.GaussianPlume(grid, source, atm)
gauss_plume.run()
signal = gauss_plume.conc
print(signal.head(5))
print(signal.tail(5))

# %%
chama.graphics.signal_convexhull(
        signal, 
        scenarios=['S'], 
        threshold=1e-5,
        x_range = x_vals, 
        y_range = y_vals, 
        z_range = z_vals
    )

plt.show()
print (signal.max())
chama.graphics.signal_xsection(signal, 'S')
plt.show()

I was assuming the value of the concentrations should not die when wind_speed nears zero. Is there something that I am missing here?

Thanks a lot for the help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.