Giter VIP home page Giter VIP logo

hmfcalc's Introduction

HMFcalc

The web-app for calculating Halo Mass Functions

NOTE: This app been improved and expanded to calculate a full range of halo model quantities. In doing so, a new repo was started, over at https://github.com/steven-murray/TheHaloMod. This repo remains for historical purposes only.

This is the source code for the HMFcalc web-app, which uses the hmf Python package to calculate halo mass functions (and other cosmological structure quantities).

The web-app is powered by Django and uses Bootstrap 4 as a CSS framework.

To acknowledge use of this app, cite Murray, Power & Robotham (2013).

Developing

Clearly, this repository is intended for developers (users shouldn't need to see this code, or I've done something wrong!). I would love contributions to this app from the community -- whether in the form of bug reports, feature requests, or new code. Please consider getting involved!

If you'd like to get involved but have never done any web-development before (like me when I started this project), I'd suggest taking the Django Beginner's Tutorial to wrap your head around things a bit.

After that, here's a bit of a primer of how this repo is laid out:

The top-level is reserved for interesting project-level stuff like this README, and scripts for managing the website itself (things you call manually when you're on the server, outside the context of the web-app itself).

The HMF directory contains the website-level settings and structure (eg. where urls point to).

The hmfstatic directory contains static files required by the website (eg javascript, images, css), which are also served as a Google app to be available via the web.

The templates directory contains the HTML files (really, they're just kinda-sorta HTML, they're actually templates) that define how each page of the website will be structured (and often, the text on the website).

Finally, the most important directory: HMFcalc. This contains the logic of the web-application, as a bunch of python files. Most important here are the views.py, which defines the various things that happen when different URLs are accessed (not always a web-page opening -- sometimes a download of a file, or a form displaying etc.), and the forms.py which defines the (fairly large) form into which inputs for the HMF are given.

Running the Server Locally

To run the local server for development, do python manage.py runserver from the top level. It should open a browser tab for you.

hmfcalc's People

Contributors

dependabot[bot] avatar steven-murray avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hmfcalc's Issues

sensitivity to CAMB parameters for high-z and/or low mass halos

hmf results seem to be sensitive to some CAMB parameters, e.g., k_per_logint and kmax, whose defaults may not be suited to high redshifts and low halo masses.

I've included a short script that shows the issue, made using hmf version 3.0.3 and camb version 0.1.7. Also, if "p.set_matter_power" is called without arguments (or even its default arguments), the results change, implying that a default MassFunction instance is perhaps not equivalent to a MassFunction instance created with a default CAMBparams object?

Note that this should be recoverable with earlier versions of hmf that used pycamb, though be aware that the relevant parameters have since changed names (from transfer__k_per_logint and transfer__kmax), and were previously passed into MassFunction via transfer_params as a simple dictionary rather than a CAMBparams instance.

Here's the test script:

import camb
from hmf import MassFunction
from matplotlib import gridspec

gs = gridspec.GridSpec(2, 1, height_ratios=[2, 1])
ax0 = pl.subplot(gs[0])
ax1 = pl.subplot(gs[1])

p = camb.CAMBparams()
p.set_matter_power(kmax=100)   # sensitive to k_per_logint as well

# These are the defaults
#p.set_matter_power([0.0], kmax=1.2, k_per_logint=None, nonlinear=None,
#    accurate_massive_neutrino_transfers=False, silent=False)

mf1 = MassFunction(Mmin=6)
mf2 = MassFunction(Mmin=6, transfer_params={"camb_params":p})

colors = ['k', 'b', 'g', 'm']
for i, z in enumerate([0, 3, 6, 10]):
    mf1.update(z=z)
    mf2.update(z=z)

    ax0.loglog(mf1.m, mf1.ngtm, color=colors[i], ls='-', label=r'$z={}$'.format(z))
    ax0.loglog(mf2.m, mf2.ngtm, color=colors[i], ls='--', lw=3)

    ax1.semilogx(mf1.m, mf2.ngtm / mf1.ngtm, color=colors[i])

ax0.legend(loc='lower left', fontsize=12)
ax0.set_ylim(1e-12, 1e5)
ax0.set_ylabel('ngtm')
ax1.set_ylabel('new/default')
ax1.set_xlabel('mass')
ax0.set_xticklabels([])

installation problems

Hi i was following the instructions to install. I was able to install pycamb as well numpy etc. when i tried to install hmf i ran into trouble. apparently there is a problem
with finding cosmolopy.perturbation

Downloading/unpacking hmf
Downloading hmf-1.1.9.tar.gz
Running setup.py egg_info for package hmf
Traceback (most recent call last):
File "", line 16, in
File "/private/var/folders/xz/79m2f5z95_xcwnqjr7xncy2r0000gn/T/pip-build-dspolyar/hmf/setup.py", line 2, in
from hmf.hmf import version
File "hmf/init.py", line 1, in
from hmf import Perturbations
File "hmf/hmf.py", line 20, in
import tools
File "hmf/tools.py", line 27, in
import cosmolopy.perturbation as pert
ImportError: No module named cosmolopy.perturbation
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

File "", line 16, in

File "/private/var/folders/xz/79m2f5z95_xcwnqjr7xncy2r0000gn/T/pip-build-dspolyar/hmf/setup.py", line 2, in

from hmf.hmf import version

File "hmf/init.py", line 1, in

from hmf import Perturbations

File "hmf/hmf.py", line 20, in

import tools

File "hmf/tools.py", line 27, in

import cosmolopy.perturbation as pert

ImportError: No module named cosmolopy.perturbation


Cleaning up...
Command python setup.py egg_info failed with error code 1 in /private/var/folders/xz/79m2f5z95_xcwnqjr7xncy2r0000gn/T/pip-build-dspolyar/hmf
Storing complete log in /Users/dspolyar/.pip/pip.log

Initial values for model parameters

At the moment, if two models for the same component have parameters of the same name, their initial form value will be whatever gets loaded last. This could lead to very strange results when someone uses the not-last model and doesn't actively set the parameter. This could probably be fixed by namespacing them more tightly.

Output file units

The column identifiers in downloaded files don't retain the information that masses are in M/h and densities are (Mpc/h)^3

planck15

put Planck+15 as the new default

model parameter info

At the moment, there is no way to specify min/max values for model parameters. This should be set to provide better validation.

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.