Skip to content

Instantly share code, notes, and snippets.

View DinoBektesevic's full-sized avatar

Dino Bektesevic DinoBektesevic

View GitHub Profile
###################################################################################################
# Create two files in the same directory to put the following code in and execute
# Uncomment one particular method of the two to test them.
# Note that runnign both tests consecutively may not give the same results because Python does
# cache the imported libraries even if they are imported in a function/method to try and avoid
# importing them twice.
# The following results were reproduced on my laptop, numbers may differ for you:
# ~/projects $: python test_import.py  ✔  6s   sktime 
$ Deferred import:
$ Slow module was imported!
@DinoBektesevic
DinoBektesevic / gist:d18cc6dcaa3ac6ff89ca395691170cc8
Last active April 26, 2024 20:37
Descriptor base config class
from contextlib import contextmanager
from tabulate import tabulate
import numbers
########################################################################################################################
# Field validators
########################################################################################################################
class ConfigField:
@DinoBektesevic
DinoBektesevic / interpolation.cpp
Created October 8, 2023 22:29
Interpolation edge cases
#include<iostream>
#include<cmath>
#include<Eigen/Core>
#include<array>
#include<assert.h>
//#define DEBUG
@DinoBektesevic
DinoBektesevic / gist:abe77efb1934eafbd46b77a09186b8c7
Created August 16, 2023 18:21
Comparison between keywords in SHARD headers of a version 0 Rubin reference catalogs and version 3
############################################################
# GAIA
############################################################
a.info()
Filename: test_imdiff_recipe/trimmedRefcats/refcats/gen2/gaia_dr2_20200414/gaia_dr2_20200414_231812_refcats_gen2.fits
No. Name Ver Type Cards Dimensions Format
0 PRIMARY 1 PrimaryHDU 6 ()
1 1 BinTableHDU 113 1060R x 21C [2X, 1K, 1D, 1D, 1D, 1D, 1D, 1D, 1D, 1D, 1E, 1E, 1D, 1D, 1D, 1E, 1E, 1D, 1D, 1D, 52A]
None
@DinoBektesevic
DinoBektesevic / config.py
Created January 20, 2023 21:21
Extensible Config class whose subclasses automatically register required and default config keys and values.
import abc
import io
import yaml
yaml_config1 ="""
version: 1
search:
param1: val1
param2: val2
region_search:
This file has been truncated, but you can view the full file.
+ cd /home/ec2-user/w_2019_31/stack/miniconda3-4.5.12-1172c30/EupsBuildDir/Linux64/verify-18.0.0-1-g9c1f36f+12
+ _EUPS_PATH=/home/ec2-user/w_2019_31/stack/miniconda3-4.5.12-1172c30
+ . /home/ec2-user/w_2019_31/eups/2.1.5/bin/setups.sh
++ export EUPS_SHELL=sh
++ EUPS_SHELL=sh
++ export EUPS_DIR=/home/ec2-user/w_2019_31/eups/2.1.5
++ EUPS_DIR=/home/ec2-user/w_2019_31/eups/2.1.5
+++ echo /home/ec2-user/w_2019_31/eups/2.1.5
+++ sed -e 's/ /-+-/g'
++ eupslocalpath=/home/ec2-user/w_2019_31/eups/2.1.5
root INFO: forced_src_schema readable (<class 'lsst.afw.table.source.source.SourceCatalog'>): PASS
root INFO: Validating source output for {'tract': 0, 'skymap': 'ci_hsc', 'instrument': 'HSC', 'visit': 903988, 'detector': '24'}
root INFO: Number of sources (3008 > 100): PASS
Touch(".scons/gen3repo-ForcedPhotCcdValidation")
python /home/ec2-user/ci_hsc/tests/test_import.py
...
----------------------------------------------------------------------
Ran 3 tests in 0.056s
OK
@DinoBektesevic
DinoBektesevic / gist:40ddd6f0935b6b17ff134a87183c2e35
Created July 19, 2019 14:26
Example AXS ingestion and crossmatch
from pyspark.sql import SparkSession
from pyspark.sql.functions import col
spark = SparkSession.builder.getOrCreate()
df = spark.read.format('parquet').load('<path_to_ingesting_file>/part-00000-4cd95544-b48a-4a67-84bb-cbcc70899ca3-c000.snappy.parquet')
df = df.withColumn('ra', col('ra_mock')).drop('ra_mock')
df = df.withColumn('dec', col('dec_mock')).drop('dec_mock')
from axs import AxsCatalog, Constants
@DinoBektesevic
DinoBektesevic / apr_utils
Last active September 18, 2018 20:06
LSST Stack build fails on logcxx step
+ cd /home/ec2-user/lsst_stack/stack/miniconda3-4.3.21-10a4fa6/EupsBuildDir/Linux64/apr_util-1.5.4
+ _EUPS_PATH=/home/ec2-user/lsst_stack/stack/miniconda3-4.3.21-10a4fa6
+ . /home/ec2-user/lsst_stack/eups/2.1.4/bin/setups.sh
++ export EUPS_SHELL=sh
++ EUPS_SHELL=sh
++ export EUPS_DIR=/home/ec2-user/lsst_stack/eups/2.1.4
++ EUPS_DIR=/home/ec2-user/lsst_stack/eups/2.1.4
+++ echo /home/ec2-user/lsst_stack/eups/2.1.4
+++ sed -e 's/ /-+-/g'
++ eupslocalpath=/home/ec2-user/lsst_stack/eups/2.1.4